• + 0 comments

    public static int sockMerchant(int n, List ar) { return ar.stream() .collect(Collectors.groupingBy(c -> c, Collectors.counting())) .values() .stream() .mapToInt(count -> (int)(count / 2)) .sum(); }