We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Yeah, good spot! Like most others, I initially parsed the input into an array to prepare it for a binary search. But, as you've pointed out, the input is coming in linearly so why not inline the search (for this particular problem). I guess it would be a different story if they asked for multiple searches on the same input though.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Intro to Tutorial Challenges
You are viewing a single comment's thread. Return to all comments →
Yeah, good spot! Like most others, I initially parsed the input into an array to prepare it for a binary search. But, as you've pointed out, the input is coming in linearly so why not inline the search (for this particular problem). I guess it would be a different story if they asked for multiple searches on the same input though.