69. x 的平方根 发表于 2021-09-27 更新于 2022-10-29 分类于 leecode刷题复习 这是文章开头,显示在主页面,详情请点击此处。 123456789101112131415class Solution: def mySqrt(self, x: int) -> int: left = 0 right = x while left<=right: half = left + (right-left)//2 if half*half == x: return half elif half*half > x: right = half - 1 end = right else: left = half + 1 end = right return end