Is there any difference between " ( low + high ) / 2 " and " low + ( high - low ) / 2 "?
When I use the first one, it told me "time limit exceed" but if I use the second one, it worked!
yes, you are right, and I meet same question, but when convert "int" into "long long int", it works.
at last, "low + (high - low)/2" is smarter!!
You are right, the same here. I think the reason is overflow, (high+low)/2 may cause a overflow when both high and low are large that makes the loop forever while (high-low)/2+low will not.
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.