Dsa
Binary Search
Warm-up
Count Occurrences of a Number
Given a sorted array and a target number, count the number of occurrences of the target in the array.
Input Format:
- The first line contains space-separated integers (sorted array).
- The second line contains an integer (target).
Output Format:
- An integer representing the count of occurrences of the target.
Example:
Input:
1 2 2 3 3 3
3
Output:
3
Key concepts
binary_searcharraycounting
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now