fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int arr[10] = {1,2,2,1,3,4,5,3,5,6};
  6. int query [2] = {2,6};
  7. // if all the number are less than 20
  8.  
  9. int hashArr[20] = {0};
  10.  
  11. for(int i = 0 ; i < 10 ; i++){
  12. hashArr[arr[i]]++;
  13. }
  14.  
  15. for(int j = 0 ; j < 2 ; j++){
  16. cout<<hashArr[query[j]]<<endl;
  17. }
  18. return 0;
  19. }
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
2
1