There is new method of binary search which may be exist but I didn't see it.
Instead of using left and right, we can simply add new bit to our answer if it is possible:
while bit > 0:
if check(ans + bit):
ans += bit
bit /= 2
Constant will be much smaller.
Oh yeah, let's make a blog for every fact that you didn't knew before. So, is that all what you've learned in your life? Pathetic.
Lol, why not? I haven't seen such implementation too, so for me this post is useful. There are too many useless blogs, but u've chosen this one))
You can do better: create a new template function with multiple parameters: left, right, a function that returns true/false.
=> you don't need to write binary search never again (except few cases).
Like this (pseudocode):