# ★★☆☆☆ 가장 큰 수
# 구현코드
import java.util.*;
public class Solution {
public String solution(int[] numbers) {
List<Integer> numberList = new ArrayList<>();
for(int number : numbers)
numberList.add(number);
Collections.sort(numberList,
(o1, o2)-> {
String front = String.valueOf(o1);
String back = String.valueOf(o2);
return Integer.parseInt(front + back) < Integer.parseInt(back + front) ? 1 :
Integer.parseInt(front + back) == Integer.parseInt(back + front) ? 0 : -1;
});
String result = "";
long sum = 0;
for(int number : numberList){
result = result + number;
sum += number;
sum %= Integer.MAX_VALUE;
}
if(sum == 0)
result = "0";
return result;
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29