You are viewing a single comment's thread. Return to all 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(); }
Seems like cookies are disabled on this browser, please enable them to open this website
Sales by Match
You are viewing a single comment's thread. Return to all 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(); }