fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include <bits/stdc++.h>
  4. using namespace std;
  5.  
  6. int main() {
  7. // your code goes here
  8.  
  9. int n;//array ka size
  10. cin>>n;
  11.  
  12. vector<int>arr(n);
  13. unordered_map<int,int>mpp;
  14.  
  15. for(int i=0;i<n;i++){
  16. cin>>arr[i];
  17. mpp[arr[i]]++;
  18. }
  19. int q;//number of queries
  20. cin>>q;
  21. for(int i=0;i<q;i++){
  22. int query;
  23. cin>>query;
  24. cout<<mpp[query]<<endl;
  25. }
  26. return 0;
  27.  
  28.  
  29. }
Success #stdin #stdout 0.01s 5324KB
stdin
3
2
2
1
2
2
3
stdout
2
0