Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. import java.util.*;
  2.  
  3. public static void main(String args[])
  4. {
  5. Scanner s = new Scanner(System.in);
  6. int x=s.nextInt();
  7. int[] arr=new int[x];
  8. int i,j,count=0;
  9. for(i=0;i<x;i++)
  10. {
  11. arr[i]=s.nextInt();
  12. }
  13. Map<Integer, Integer> check=new HashMap<Integer, Integer>();
  14. for(i=0;i<x;i++)
  15. {
  16. for(j=0;j<x;j++)
  17. {
  18. if(arr[i]==arr[j])
  19. {
  20. count++;
  21. }
  22. }
  23. check.put(arr[i], count);
  24. count=0;
  25. }
  26. int y=s.nextInt();
  27. int[] brr=new int[y];
  28. for(i=0;i<y;i++)
  29. {
  30. brr[i]=s.nextInt();
  31. }
  32. Map<Integer, Integer> check1=new HashMap<Integer, Integer>();
  33. int count1=0;
  34. for(i=0;i<y;i++)
  35. {
  36. for(j=0;j<y;j++)
  37. {
  38. if(brr[i]==brr[j])
  39. {
  40. count1++;
  41. }
  42. }
  43. check1.put(brr[i], count1);
  44. count1=0;
  45. }
  46. System.out.println(check);
  47. System.out.println(check1);
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement