fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int arr[] = {1, 1, 2, 2, 3, 4, 5};
  6. int queries[] = {1, 2, 3};
  7. int n = 7;
  8. int q = 3;
  9.  
  10. int freq[6] = {0};
  11.  
  12. int i = 0;
  13. while(i < n) {
  14. freq[arr[i]]++;
  15. i++;
  16. }
  17.  
  18. int j = 0;
  19. while(j < q) {
  20. cout << freq[queries[j]] << endl;
  21. j++;
  22. }
  23.  
  24. return 0;
  25. }
  26.  
Success #stdin #stdout 0s 5316KB
stdin
Standard input is empty
stdout
2
2
1