# Binary search
def mySqrt(self, x):
l, r = 0, x
while l <= r:
mid = l + (rl)//2
if mid * mid <= x < (mid+1)*(mid+1):
return mid
elif x < mid * mid:
r = mid
else:
l = mid + 1
Python binary search solution (O(lgn)).

@caikehe said in Python binary search solution (O(lgn)).:
mid * mid <= x < (mid+1)*(mid+1)
can anyone explain what mid * mid <= x < (mid+1)*(mid+1) does?