You are viewing a single comment's thread. Return to all comments →
My C++ solution
int sockMerchant(int n, vector<int> ar) { std::vector<bool> odds = std::vector<bool>(100); int nPairs = 0; for ( int sockID : ar ) { if ( odds[sockID-1] ) { nPairs++; odds[sockID-1] = false; } else { // odd sock found odds[sockID-1] = true; } } return nPairs; }
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 →
My C++ solution