You know what Jonathan? I think you found a bug, because uniqueScores[mid — 1 > score] really should evaluate to a boolean, which should then return undefined when looking up a boolean in the uniqueScores array. Intuitively, it really feels like the code should be uniqueScores[mid — 1] > score

I changed the code in HackerRank, and some tests passed, and some failed. I tried looking at the failed tests, and of course, they’re crazy long, and not very useful.

I suggest your main takeaway ought to be the algorithm, and you can use the these steps to pseudocode your own solution.

Sorry I couldn’t be much more help!


Always learning.

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store