public class Main2 {
public static void main(String[] args) {
System.out.println(new Solution().solution(45));
}
}
class Solution {
public int solution(int n) {
StringBuilder sb = new StringBuilder(Integer.toString(n, 3));
int answer = Integer.parseInt(sb.reverse().toString(), 3);
return answer;
}
}
처음에는 어떻게 풀지 몰랐다. Integer.toString()
에 진법변환이 있는 줄도 몰랐다. 검색해본 결과 진법변화를 Integer.toString()
으로 할 수 있어서 사용.
하나 배웠다아 !
[링크]:개인저장소