All Tracks Data Structures Hash Tables Basics of Hash Tables Problem

Easy one
/
No tags
Problem
Editorial
Analytics

Aurora is the Annual Cultural Festival of IIITM Gwalior which also happens to be Central India's largest Cultural Festival...! This year the promotion team of Aurora is distributing free passes for the fest if one can successfully answer the following question :

Given an array 'A' of 'N' non-negative integers and 'Q' queries. Each query consist of a single integer 'X', you have to simply tell the no. of occurrences of integer 'X' in the given array 'A'.

Input :

  • First line consists of an integer 'T' i.e. the no. of test cases.
  • First line of each test case consists of two space separated integers 'N' and 'Q' i.e. the no. of elements in the array and no. of queries.
  • Next line contains 'N' space separated non-negative integers.
  • Following 'Q' lines contains a single non-negative integer 'X'.

Output :

  • For each query output the no. of occurrences of 'X' in the given array.

Constraints :

  • 1<=T<=10
  • 1<=N<=105
  • 1<=Q<=105
  • 0<=array element Ai<=109
  • 0<=X<=109
SAMPLE INPUT
1
5 3
5 8 1 4 5
1
5
3
SAMPLE OUTPUT
1
2
0
Explanation

Self Explanatory.

Time Limit: 2.0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB

Best Submission

Similar Problems

Contributors

Initializing Code Editor...
Notifications
View All Notifications

?