You are viewing a single comment's thread. Return to all comments →
Solution C#:
public static int sockMerchant(int n, List<int> ar) { int pairCount = 0; var sockDict = new Dictionary<int , int>(); foreach(var item in ar){ if(sockDict.ContainsKey(item)){ sockDict[item] += 1; } else { sockDict[item] = 1; } } foreach(var kvp in sockDict){ pairCount+= (int)kvp.Value/2; } return pairCount; }
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 →
Solution C#: