Skip to content

Commit 511e84f

Browse files
authored
Merge pull request #1284 from AlgorithmWithGod/ksinji
[20251031] PGM / LV2 / 가장 큰 수 / 강신지
2 parents c64322e + 788ee40 commit 511e84f

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
```java
2+
import java.util.*;
3+
4+
class Solution {
5+
public String solution(int[] numbers) {
6+
String[] arr = new String[numbers.length];
7+
for (int i = 0; i < numbers.length; i++) {
8+
arr[i] = String.valueOf(numbers[i]);
9+
}
10+
11+
Arrays.sort(arr, (a, b) -> (b + a).compareTo(a + b));
12+
13+
if (arr[0].equals("0")) return "0";
14+
15+
StringBuilder sb = new StringBuilder();
16+
for (String s : arr) sb.append(s);
17+
return sb.toString();
18+
}
19+
}
20+
```

0 commit comments

Comments
 (0)