Practice · 1 of 5
Count Occurrences
CHALLENGE
Difficulty: beginner+25 XP
**Description:** Given a sorted array of n integers and q queries, for
each query value x print how many times x appears in the array.
**Input:** Line 1: n q (1 <= n, q <= 10^5). Line 2: n integers in
non-decreasing order (|a_i| <= 10^9). Next q lines: x (|x| <= 10^9).
**Output:** q lines — the count for each query (0 if absent).
**Example:** 6 2 / 1 2 2 2 5 9 / 2 / 7 -> 3, 0.
Press Submit to check your solution.
Back to lesson: Practice: Search Set