class Solution {
public:
bool isPerfectSquare(int num) {
int l=1,r=num;
while(l<=r)
{
int mid=l+(r-l)/2;
if((long long) mid*mid <=num)
l=mid+1;
else if ((long long) mid*mid > num)
r=mid-1;
}
return ((long long) r*r == num );
}
};
05-06
231
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)