69. Sqrt(x)
- 題目描述
- 思路分析
- 代碼實作
題目描述
點這里
思路分析
二分
代碼實作
class Solution {
public:
int mySqrt(int x) {
long long l=0,r=x;
while(l<r){
int mid=l+r+1>>1;
if((long long)mid*mid<=x) l=mid;
else r=mid-1;
}
return l;
}
};
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/330128.html
標籤:其他
