Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public static void main(String args[])
- {
- Scanner s = new Scanner(System.in);
- int x=s.nextInt();
- int[] arr=new int[x];
- int i,j,count=0;
- for(i=0;i<x;i++)
- {
- arr[i]=s.nextInt();
- }
- Map<Integer, Integer> check=new HashMap<Integer, Integer>();
- for(i=0;i<x;i++)
- {
- for(j=0;j<x;j++)
- {
- if(arr[i]==arr[j])
- {
- count++;
- }
- }
- check.put(arr[i], count);
- count=0;
- }
- int y=s.nextInt();
- int[] brr=new int[y];
- for(i=0;i<y;i++)
- {
- brr[i]=s.nextInt();
- }
- Map<Integer, Integer> check1=new HashMap<Integer, Integer>();
- int count1=0;
- for(i=0;i<y;i++)
- {
- for(j=0;j<y;j++)
- {
- if(brr[i]==brr[j])
- {
- count1++;
- }
- }
- check1.put(brr[i], count1);
- count1=0;
- }
- System.out.println(check);
- System.out.println(check1);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement