class Solution {
public long solution(long n) {
long answer = 0;
int[] count = new int[10];
while (n != 0) {
count[(int) (n % 10)]++;
n /= 10;
}
for (int i = 9; i >= 0; i--) {
for (int j = 0; j < count[i]; j++) {
answer *= 10;
answer += i;
}
}
return answer;
}
}
출처: 프로그래머스 코딩 테스트 연습, https://programmers.co.kr/learn/challenges