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.
I disagree, 1-based indices are most frequent in the real world and it's useful to keep the habit to juggle with that.
(All you have to do is to add +1 to each of the indices in the print statement, not a big deal !)
It's also most common in applications that you search for an item by its price or name etc but you want to get the id of it.
The confusin thing is that this problem is tagged "binary search" while that search is hidden in the dictionary lookup implemented by the system, at least if one has dict/map or equivalent as part of the language.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Hash Tables: Ice Cream Parlor
You are viewing a single comment's thread. Return to all comments →
I disagree, 1-based indices are most frequent in the real world and it's useful to keep the habit to juggle with that.
(All you have to do is to add +1 to each of the indices in the print statement, not a big deal !)
It's also most common in applications that you search for an item by its price or name etc but you want to get the id of it.
The confusin thing is that this problem is tagged "binary search" while that search is hidden in the dictionary lookup implemented by the system, at least if one has dict/map or equivalent as part of the language.