You are viewing a single comment's thread. Return to all comments →
Java using Collections frequency utility:
public static int sockMerchant(int n, List<Integer> ar) { Set<Integer> unique = new HashSet<>(ar); int pairs = 0; for(Integer i : unique){ Integer frequency = Collections.frequency(ar, i); pairs = pairs + (frequency / 2); } return pairs; }
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 →
Java using Collections frequency utility: