Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - Java looks for numbers that are repeated three times in a set of integers.
Java looks for numbers that are repeated three times in a set of integers.
int[]arr = { 66999 1 1,5, 1,66, 100,68,45,7, 1 1,66,66, 1 1 }; //Duplicate number 66, 1 1

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);

}

}