You are viewing a single comment's thread. Return to all comments →
Initial solution in JS. I will post an optimized solution later.
function sockMerchant(n, ar){ let pairCount = 0; while(ar.length>1) { for(let i = 1; i < ar.length; i++) { if(ar[0] === ar[i]) { pairCount += 1 ar.splice(0, 1) ar.splice(i-1, 1) i = 0 } } ar.splice(0, 1) } 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 →
Initial solution in JS. I will post an optimized solution later.