https://school.programmers.co.kr/learn/courses/30/lessons/68935
class Solution {
public int solution(int n) {
int answer = 0;
String result="";
int sum=0;
while(true){
result+= n%3;
n = n/3;
if(n==0){
break;
}
}
int[] result2 = new int[result.length()];
for(int i =0; i<result.length(); i++){
result2[i] = result.charAt(i)-'0';
}
int tmp=1;
for(int i= result2.length-1; i>=0; i--){
sum += result2[i]*tmp;
tmp *=3;
}
return sum;
}
}