Skip to content

Commit 8504ccc

Browse files
committed
[20251117] PGM / LV2 / 가장 큰 수 / 김민진
1 parent d22daf8 commit 8504ccc

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
```java
2+
import java.util.Arrays;
3+
4+
public class PGM_LV2_가장_큰_수 {
5+
6+
private static int len;
7+
private static String answer;
8+
private static String[] nums;
9+
10+
public String solution(int[] numbers) {
11+
answer = "";
12+
len = numbers.length;
13+
nums = new String[len];
14+
15+
for (int i = 0; i < len; i++) {
16+
nums[i] = String.valueOf(numbers[i]);
17+
}
18+
Arrays.sort(nums, (a, b) -> (b + a).compareTo(a + b));
19+
20+
if (nums[0].equals("0")) return "0";
21+
22+
for (int i = 0; i < len; i++) {
23+
answer += nums[i];
24+
}
25+
return answer;
26+
}
27+
28+
}
29+
```

0 commit comments

Comments
 (0)