```
public class Solution {
public boolean isPerfectSquare(int num) {
if (num < 0) return false;
if (num == 0) return true;
int start = 1, end = num, mid = 0;
while (start <= end) {
mid = (end - start) / 2 + start;
if (mid * mid > num || mid * mid <= 0) end = mid - 1;
else if (mid * mid < num ) start = mid + 1;
else return true;
}
return start * start == num;
}
}
```