
二分查找法

代码
public int mySqrt(int x){
int l = 0, r = x,ans = -1;
while(l <= r){
int mid = l + (r - l) / 2;
if((long) mid * mid <= x){
ans = mid;
l = mid + 1;
}
else{
r = mid - 1;
}
}
return ans;
}







![Vue [Day2]](https://img-blog.csdnimg.cn/167e8c4bf9514b6d8c4c2047a94f9973.png)











