You are viewing a single comment's thread. Return to all comments →
Java
int[] pairs = new int[100]; int pairCount = 0; for (int i: ar) pairs[i - 1]++; for(int i: pairs) pairCount += (i / 2); return pairCount; }
C++
int sockMerchant(int n, vector<int> ar) { vector<int> pairs(100, 0); for (int i: ar) pairs[i - 1]++; int pairCount = 0; for (int i = 0; i < 100; i++) { pairCount += (pairs[i] / 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 →
Simple Solution
Java
C++