Skip to content

Instantly share code, notes, and snippets.

@rakibulalam
Last active May 5, 2020 22:55
Show Gist options
  • Save rakibulalam/44118e944efb3cedc094fc23a80f61b7 to your computer and use it in GitHub Desktop.
Save rakibulalam/44118e944efb3cedc094fc23a80f61b7 to your computer and use it in GitHub Desktop.
Luck Balance Hacker Rank
function luckBalance(k, contests) {
return contests.sort(([a,x],[b,y])=>y-x || b-a)
.reduce((memo,[l,t],key)=>{
memo += t===1 && key<k? l: t===1 && key>=k?-l:l
return memo;
},0)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment