almost same invariants as sqrt problem

```
public boolean isPerfectSquare(int num) {
if (num < 2) return true;
int l = 1, u = num / 2;
while(l < u) {
int m = u - (u - l)/2;
if (m > num / m) {
u = m - 1;
} else {
l = m;
}
}
return u * u == num;
}
```