fork download
  1. //hashing session 0 code 1 by seeing,understanding and copying
  2. import java.util.Scanner;
  3. public class Main{
  4. public static void main(String[] args){
  5. Scanner sc = new Scanner(System.in);
  6. int n=sc.nextInt();
  7. int[] array=new int[n];
  8. for(int i=0;i<n;i++){
  9. array[i]=sc.nextInt();
  10. }
  11. int q=sc.nextInt();
  12. for(int i=0;i<q;i++){
  13. int query=sc.nextInt();
  14. int count=0;
  15. for(int j=0;j<n;j++){
  16. if(array[j]==query){
  17. count++;
  18. }
  19. }
  20. System.out.println(count);
  21. }
  22. }
  23. }
Success #stdin #stdout 0.12s 54632KB
stdin
8
0 1 2 3 2 1 3 4
4
2
3
0
5
stdout
2
2
1
0