public class Solution {

    public boolean isPerfectSquare(int num) {

        for (int i = 1; num > 0; i += 2) {
            num -= i;
        }

        return num == 0;

    }

}

Create : 367 Valid Perfect Square
Create : 367 Valid Perfect Square
