How Many Times Does X Appear
Given the array once and then Q queries, print how many times each queried value occurs.
Input: the first line has N and Q; the second line has the array; the next Q lines each have one query value.
Output: Q lines with the frequencies (0 for absent values).
Constraints:
- 1 ≤ N, Q ≤ 105
- |values| ≤ 109
Sample Tests
Input 1
5 3 1 2 2 3 2 2 4 1
Output 1
3 0 1
Input 2
1 1 7 7
Output 2
1
Discussion (opens after you solve — no spoilers before)
No comments yet.