based on math:

https://en.wikipedia.org/wiki/Square_number

and another great solution:

https://leetcode.com/discuss/110638/a-square-number-is-1-3-5-7-java-code

The complexity is easy to understand from wiki page.

```
class Solution {
public:
bool isPerfectSquare(int num) {
for (int i = 1; num > 0; i += 2)
num -= i;
return !num;
}
};
```