1. Description
2. Solution
代码语言:javascript复制class Solution {
public:
bool isPerfectSquare(int num) {
int left = 0;
int right = num;
while(left <= right) {
long mid = (left right) / 2;
long square = mid * mid;
if(square == num) {
return true;
}
if(square > num) {
right = mid - 1;
}
else {
left = mid 1;
}
}
return false;
}
};