两种二分模板的选择
[l, mid-1], [mid, r] 和 [l, mid], [mid+1, r]
class Solution {
public:
int mySqrt(int x) {
long long l = 0, r = x;
while (l < r){
long long mid = l + r + 1 >> 1;
if (mid * mid <= x) l = mid;
else r = mid - 1;
}
return l;
}
};