You are viewing a single comment's thread. Return to all comments →
`
int sockMerchant(int n, vector ar) { std::sort(ar.begin(),ar.end()); int pairs = 0;
for (int i = 0; i < n - 1;) { if (ar[i] == ar[i + 1]) { pairs++; i += 2; } else { i += 1; } } 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 →
`
int sockMerchant(int n, vector ar) { std::sort(ar.begin(),ar.end()); int pairs = 0;
}
`