You are viewing a single comment's thread. Return to all comments →
Here is my answer using java language You can check my Project Euler ans on github.
static int migratoryBirds(List<Integer> arr) { Map<Integer, Integer> birds = new HashMap<>(); int key = 0; for(int i = 0; i < arr.size(); i++){ if(birds.containsKey(arr.get(i))){ birds.put(arr.get(i), birds.get(arr.get(i)) + 1); }else{ birds.put(arr.get(i), 1); } } key = Collections.max(birds.entrySet(), Map.Entry.comparingByValue()).getKey(); return key; }
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 →
Here is my answer using java language You can check my Project Euler ans on github.