Skip to content

Instantly share code, notes, and snippets.

@rakibulalam
Last active May 5, 2020 22:56
Show Gist options
  • Save rakibulalam/f0d430c3e4c157e63316e883ebdf8caa to your computer and use it in GitHub Desktop.
Save rakibulalam/f0d430c3e4c157e63316e883ebdf8caa to your computer and use it in GitHub Desktop.
Sock Merchant Hacker Rank
function sockMerchant(n, ar) {
const pairs={};
return ar.reduce((memo,value)=>{
if(pairs.hasOwnProperty(value))
{
pairs[value]=pairs[value]+1;
memo+=pairs[value]%2===0?1:0
}else{
pairs[value]=1
}
return memo;
},0)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment