forked from rahulkumarproc/Hackto21
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcountofnousinghashing.cpp
More file actions
48 lines (44 loc) · 866 Bytes
/
countofnousinghashing.cpp
File metadata and controls
48 lines (44 loc) · 866 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//given array a of N integers . Given Q queries and in each query a given number X , print count of thta number in array.
/*#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
int a[n];
for(int i=0;i<n;i++)
cin>>a[i];
int q;
cin>>q;
while(q--){
int x;
cin>>x;
int ct=0;
for(int i=0;i<n;i++){
if(a[i]==x)
ct++;
}
cout<<ct<<endl;
}
return 0; // O(n^2)
}*/
#include<bits/stdc++.h>
using namespace std;
const int N=1e7+10;
int hsh[N];
int main(){
int n;
cin>>n;
int a[n];
for(int i=0;i<n;i++){
cin>>a[i];
hsh[a[i]]++;
}
int q;
cin>>q;
while(q--){
int x;
cin>>x;
cout<<hsh[x]<<endl;
}
return 0;
//O(N)