fork download
  1. #include <iostream>
  2. #include<bits/stdc++.h>
  3. using namespace std;
  4.  
  5. int main() {
  6. int arr[10] = {1,2,2,1,3,4,5,3,5,6};
  7. int query [2] = {2,6};
  8.  
  9. unordered_map<int,int> hash ;
  10.  
  11. for(int i = 0 ; i < 10 ; i++){
  12. hash[arr[i]]++;
  13. }
  14.  
  15. for(int j = 0 ; j < 2 ; j++){
  16. cout<<hash[query[j]]<<endl;
  17. }
  18. return 0;
  19. }
Success #stdin #stdout 0.01s 5268KB
stdin
Standard input is empty
stdout
2
1