```
public class Solution {
public boolean isPerfectSquare(int num) {
int l=1,r=num;
while(l<r){
int mid=l+(r-l)/2;
if(mid<num/mid)
l=mid+1;
else
r=mid;
}
return l==(double)num/l;
}
}
```