69. Sqrt(x)python
題目大意:code
求一個數的平方根blog
思路:ip
二分查找leetcode
Python實現:get
def sqrt(x): l = 0 r = x + 1 while l < r: m = l + (r - l) // 2 if m * m > x: r = m else: l = m + 1 return l - 1