Skip to content

Commit e449bfe

Browse files
authored
[20251110] PGM / LV2 / 가장 큰 수 / 이인희
1 parent 4833179 commit e449bfe

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
```java
2+
import java.util.*;
3+
4+
class Solution {
5+
public String solution(int[] numbers) {
6+
String[] strs = new String[numbers.length];
7+
for(int i = 0; i < numbers.length; i++){
8+
strs[i] = String.valueOf(numbers[i]);
9+
}
10+
11+
Arrays.sort(strs, new Comparator<String>() {
12+
@Override
13+
public int compare(String a, String b) {
14+
String ab = a + b;
15+
String ba = b + a;
16+
return ba.compareTo(ab);
17+
}
18+
});
19+
20+
if(strs[0].equals("0")){
21+
return "0";
22+
}
23+
24+
StringBuilder sb = new StringBuilder();
25+
for(String s : strs){
26+
sb.append(s);
27+
}
28+
29+
return sb.toString();
30+
}
31+
}
32+
33+
```

0 commit comments

Comments
 (0)