Migratory Birds

  • + 0 comments

    Java solution

    public static int migratoryBirds(List<Integer> arr) {
            var groups = arr.stream().collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
            return groups.entrySet().stream().max(Map.Entry.comparingByValue()).map(Map.Entry::getKey).orElse(0);
        }