[Programmers] 124 나라의 숫자 (12899번) - Java Solution
문제
- https://programmers.co.kr/learn/courses/30/lessons/12899
Solution
class Solution {
public String solution(int n) {
String data[] = {"4", "1", "2"};
String answer = "";
int remainder = 0;
while(n > 0) {
remainder = n % 3;
n = (n-1)/3;
answer = data[remainder] + answer;
}
return answer;
}
}
Leave a comment