You are viewing a single comment's thread. Return to all comments →
Similar solution in JavaScript:
function sockMerchant(n, ar) { const colors = {}; let matches = 0; for (let i = 0; i < n; i++) { if (colors[ar[i]]) { matches++; colors[ar[i]] = 0; } else { colors[ar[i]] = 1; } } return matches; }
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 →
Similar solution in JavaScript: