You are viewing a single comment's thread. Return to all comments →
public static int migratoryBirds(List<Integer> arr) { int max = Integer.MIN_VALUE; int count = 0; int idMin = Integer.MAX_VALUE; int id = 0; Collections.sort(arr); for (int i = 0, j = 1; j < arr.size() - 1; i++, j++) { if (arr.get(i) == arr.get(j + 1)) { id = arr.get(i); count++; if (count > max) { max = count; idMin = id; } } else { count = 0; } } return idMin; }
Seems like cookies are disabled on this browser, please enable them to open this website
Migratory Birds
You are viewing a single comment's thread. Return to all comments →
Java