Playground/자바문제집

[프로그래머스] 정수 제곱근 판별

미숫가루설탕많이 2023. 2. 8. 14:20
class Solution {
    public long solution(long n) {
        Double num = Math.sqrt(n);
        return num == num.intValue() ? (long)Math.pow(num + 1, 2) : -1;
    }
}