• + 0 comments
    public static int migratoryBirds(List<Integer> arr) {
        return arr.stream()
            .collect(Collectors.groupingBy(Function.identity(), Collectors.counting()))
            .entrySet().stream()
        .sorted((a, b) -> (int) (b.getValue() - a.getValue()))
        .mapToInt(es -> es.getKey())
        .findFirst()
        .getAsInt();
    }