본문 바로가기

Coding Test/프로그래머스

[프로그래머스/자바] 3진법 뒤집기

class Solution {
    public int solution(int n) {
        String s = Integer.toString(n, 3);
        String reversed = new StringBuilder(s).reverse().toString();
        
        return Integer.parseInt(reversed, 3);
    }
}