알고리즘

[프로그래머스] 3진법 뒤집기(Java) *

muerha 2024. 11. 24. 23:07

 

 

 


 

 

나의 풀이

class Solution {
    public int solution(int n) {
         String str = "";

        while (n != 0) {
            str += n % 3;
            n /= 3;
        }
        
        return Integer.parseInt(str, 3);
    }
}

 

 

 

수학공부부터 다시 해야겠네