思路:
// @Title: 有效的完全平方数 (Valid Perfect Square)
// @Author: qisiii
// @Date: 2024-09-06 17:21:32
// @Runtime: 0 ms
// @Memory: 39.5 MB
// @comment:
// @flag:
class Solution {
public boolean isPerfectSquare(int num) {
int left=1,right=num;
while(left<=right){
int mid=left+(right-left)/2;
long sum=(long)mid*mid;
if(sum==num){
return true;
}else if(sum>num){
right=mid-1;
}else{
left=mid+1;
}
}
return false;
}
}