본문 바로가기
알고리즘 문제풀이/Programmers - 자바

프로그래머스 - 제곱수 판별하기

by 올리브영 2023. 3. 3.
728x90
반응형
class Solution {
    public int solution(int n) {
        for(int i=1; i<1000001; i++){
            if(i*i == n){
                return 1;
            }
        }
        return 2;
    }
}
728x90
반응형