Count of an Element in a Sorted Array
Medium

Problem Statement

Given a sorted array `nums` and a `target` value, return the number of times the target appears in the array. If the target is not found, return 0.

Examples

1Example 1
Input:
{ "nums": [ 5, 7, 7, 8, 8, 10 ], "target": 8 }
Output:
2
2Example 2
Input:
{ "nums": [ 5, 7, 7, 8, 8, 10 ], "target": 6 }
Output:
0
3Example 3
Input:
{ "nums": [], "target": 0 }
Output:
0
Loading...

Sign in to Run Code and Submit