class Solution {
public boolean isPerfectSquare(int num) {
int left = 1;
int right = num;
int mid;
while(left <= right){
mid = left + (right - left) / 2;
long res = (long)mid * mid;
if(res > num){
right = mid - 1;
}else if(res < num){
left = mid + 1;
}else{
return true;
}
}
return false;
}
}
java有效的完全平方数
最新推荐文章于 2024-03-23 20:26:26 发布