fork download
  1. #include <iostream>
  2. #include<bits/stdc++.h>
  3. using namespace std;
  4.  
  5. int main() {
  6. // your code goes here
  7. int n,q ; cin>>n>>q;
  8. vector<int>arr(n);
  9. unordered_map<int,int>hash;
  10.  
  11. for(int i=0;i<n;i++){
  12. cin>>arr[i];
  13. hash[arr[i]]++;
  14. }
  15.  
  16. for(int i =0;i<q;i++){
  17. int query;
  18. cin>>query;
  19. cout<<hash[query]<<" ";
  20. }
  21.  
  22. return 0;
  23. }
Success #stdin #stdout 0.01s 5316KB
stdin
10 3
3 2 4 1 2 1 5 4 2 1
1 2 4
stdout
3 3 2