Map & ltString, Integer & gt map = new hashmap & lt string, integer & gt (); //map stores each integer and its occurrence times.
for(int temp : arr){
If (! map.containsKey(temp+" "))
map.put(temp+" ", 1);
Otherwise {
;
map . put("+temp,map . get(temp+" ")+ 1); //Number of occurrences plus 1
}
if(map.get(temp+"")==3)
system . out . println(temp);
}
}