fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6. import java.util.Scanner;
  7.  
  8. /* Name of the class has to be "Main" only if the class is public. */
  9. class Ideone
  10. {
  11. public static void main (String[] args) throws java.lang.Exception
  12. {
  13. Scanner in = new Scanner(System.in);
  14. int n = in.nextInt();
  15. int arr[] = new int[n];
  16. int hasharr[] = new int[51];
  17.  
  18. for(int i =0;i<n;i++){
  19. arr[i] = in.nextInt();
  20. hasharr[arr[i]] = hasharr[arr[i]] + 1;
  21. }
  22.  
  23. int queries = in.nextInt(); // Number of queries
  24. for(int i=0;i<queries;i++){
  25. int count=0;
  26. int query = in.nextInt();
  27. count = hasharr[query];
  28. System.out.println(count);
  29. }
  30.  
  31. }
  32. }
Success #stdin #stdout 0.14s 54572KB
stdin
5
1 1 2 3 3
2
1
2
stdout
2
1