You are viewing a single comment's thread. Return to all comments →
Java 8 solution
public static int sockMerchant(int n, List ar) {
Set<Integer> sock = new HashSet<>(); int pairs = 0; for(int ele: ar){ if(sock.contains(ele)){ pairs++; sock.remove(ele); } else{ sock.add(ele); } } 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 8 solution
public static int sockMerchant(int n, List ar) {