Why Brute Force Worked But Binary search doesn't?

You’ve missed out most of your code so it’s hard to tell where the error lies, but this:

looks like very overflow-ish.

It’s pretty easy to find out for (almost) sure.

2 Likes