Practice Arena
[Exp 3] Binary Search with Target Count
UNIT-III Rubric: 10m Code + 5m Viva + 5m Record MEDIUM 15 Marks
Session: 59:59
Bubblewrap Sandbox Active
Problem Statement
Given a sorted array of N integers in non-decreasing order, count the total occurrences of a target integer K using an efficient O(log N) algorithm. Print the total frequency of K in the array, or 0 if K is not present.
Input Format
Line 1 contains two integers N and K. Line 2 contains N sorted space-separated integers.
Output Format
Print the total number of times K appears in the array.
Constraints
1 <= N <= 2 * 10^5 -10^9 <= A[i], K <= 10^9
Status Lang Score Time Submitted
No prior submissions for this problem.
Ready
Click Run Code to evaluate against sample test cases, or Submit Solution for full evaluation.
Instructor Guidance