fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. int n, q;
  6. cin >> n;
  7. unordered_map<int, int> hash_map;
  8. int array[n];
  9. for (int i = 0; i < n; i++) {
  10. cin >> array[i];
  11. hash_map[array[i]] = hash_map[array[i]] + 1;
  12. }
  13.  
  14. cin >> q;
  15.  
  16. for (int i = 0; i < q; i++) {
  17. int query;
  18. cin >> query;
  19.  
  20. int count = hash_map[query];
  21. cout << count << endl;
  22. }
  23.  
  24. return 0;
  25. }
Success #stdin #stdout 0s 5320KB
stdin
5
5 3 2 5 1
2
5
3
stdout
2
1