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