private static int countDuplicates(int arr[]){
HashMap<Integer,Integer> map = new HashMap<>();
for(int num:arr){
map.put(num,map.getOrDefault(num,0) + 1);
}
int count = 0;
for(Map.Entry<Integer,Integer> m:map.entrySet()){
if(m.getValue() > 1) count++;
}
return count;
}
}