LeetCode69 x的平方根
class Solution(object):
def mySqrt(self, x):
"""
:type x: int
:rtype: int
"""
l, r, ans = 0, x, -1
while l <= r:
mid = (l + r) // 2
if mid * mid <= x:
ans = mid
l = mid + 1
else:
r = mid - 1
return ans
标签:二分,rtype,LeetCode69,self,object,int,平方根
来源: https://www.cnblogs.com/solvit/p/16422515.html