Challenge II

4.7

3 votes
Binary Search, Easy
Problem

You are given an array A of n sorted numbers. You are also given m queries of the form x. Your task is to output the number of times the number x occurs within the array.

Constraints

The values in the array will range from -10^9 to 10^9.
1 <= n <= 10^5
1 <= m <= 2*10^5

Input and Output

The input consists of n on the first line followed by the array on the next.
After that m on the next line followed by m queries. For each of the m queries, print on a separate line, the number of occurrences in the array.

Time Limit: 1
Memory Limit: 256
Source Limit:
Editor Image

?