You are viewing a single comment's thread. Return to all comments →
C#
public static int sockMerchant(int n, List<int> ar) { if(ar.Count() == 1) return 0; ar.Sort(); var pairs = 0; var i = 0; while(ar.Count() != 0){ if(ar.Count() == 1) break; else if(ar[i] == ar[i + 1]) { ++pairs; ar.RemoveRange(0, 2); i = 0; } else ar.RemoveAt(i); } 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 →
C#