You are viewing a single comment's thread. Return to all comments →
just because, there are no many sock types. o(n)
int sockMerchant(int n, vector<int> ar) { static int socksTypesMax = 100; vector<int> cs(socksTypesMax); for (const int& a : ar) { ++cs[a - 1]; } return accumulate(cs.cbegin(), cs.cend(), 0, [](int l, int r) { return l + r / 2; }); }
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 →
just because, there are no many sock types. o(n)