69-x的平方根

tech2023-01-23  90

class Solution { public: int mySqrt(int x) { int left = 0, right = x / 2 + 1; int res = 0; while (left <= right) { int mid = (left + right) >> 1; if (((long long) mid * mid <= x)) { left = mid + 1; res = mid; } else { right = mid - 1; } } return res; } };
最新回复(0)