What i did
- 알고리즘 프로그래머스
class Solution {
public int solution(String s) {
int answer = 0;
answer = Integer.parseInt(s);
return answer;
}
}
import java.util.*;
class Solution {
public long solution(long n) {
String answer = "";
String str = Long.toString(n);
Integer[] arr = new Integer[str.length()];
for(int i =0;i<str.length();i++){
String s = str.substring(i,i+1);
arr[i] = Integer.parseInt(s);
}
Arrays.sort(arr, Collections.reverseOrder());
for(int i=0;i<str.length();i++){
answer += arr[i];
}
return Long.parseLong(answer);
}
}