@lixiaolun@ChengZhang But if it is exceeding the integer limit it should show some kind of OutOfIndex but why is it showing the
Time Limit Exceed.
Thank You

@zilan (start + end) can overflow the int range and it will give a garbage value which will be divided by 2. start + (end - start)/2 does not let that happen. Keeps everything in the int range.

Because your ( Start + end ) value can go beyond Integer.MAX_VALUE and hence giving you a negative value.
Eg : start = 1073741824 , end = 1073741827
if mid = (start + end) /2 the mid = 2147483651/2

Here the numerator is more than the integer range in java. hence making mid = -2147483644/2 = -1073741822 which is wrong

if mid = start + (end - start)/2 then
mid = 1073741824 + 1 = 1073741825

Hmm, I believe I've seen that article before, and thus also that >>> solution, so must have forgotten. I guess I *really* don't care about the issue :-)