You are viewing a single comment's thread. Return to all comments →
public static int migratoryBirds(List<Integer> arr) { // Write your code here Map<Integer,Integer> map = new HashMap<>(); for(Integer num : arr) { map.put(num, map.getOrDefault(num,0)+1); } int max=0; for(Integer values : map.values() ) { if(max< values) max= values; } for(Map.Entry<Integer, Integer> keySet : map.entrySet() ){ if(keySet.getValue() == max) { return keySet.getKey(); } } return 0; }
}
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 →
}