You are viewing a single comment's thread. Return to all comments →
public static int sockMerchant(int n, List<Integer> ar) { Collections.sort(ar); int count = 0, pair = 0, element = ar.get(0); for(Integer i : ar){ if (i == element) count++; else{ pair += count/2; count = 1; element = i; } } pair += count/2; return pair; }
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 →