본문 바로가기
Beakjoon&프로그래머스/Java

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

by 현장 2025. 2. 25.

-Code

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