File tree Expand file tree Collapse file tree 2 files changed +18
-17
lines changed
Expand file tree Collapse file tree 2 files changed +18
-17
lines changed Original file line number Diff line number Diff line change 44
55### 성능 요약
66
7- 메모리: 123 MB, 시간: 190.55 ms
7+ 메모리: 160 MB, 시간: 443.88 ms
88
99### 구분
1010
1616
1717### 제출 일자
1818
19- 2025년 09월 02일 18:20:18
19+ 2025년 09월 16일 10:02:20
2020
2121### 문제 설명
2222
Original file line number Diff line number Diff line change 22
33class Solution {
44 public String solution (int [] numbers ) {
5- // 사전 순 정렬
6- ArrayList <String > strList = new ArrayList <>();
7- for (int number : numbers ){
8- strList .add (String .valueOf (number ));
9- }
10- Collections .sort (strList ,new Comparator <String >(){
5+
6+ PriorityQueue <String > pq = new PriorityQueue <>(new Comparator <String >(){
7+
118 @ Override
12- public int compare (String s1 , String s2 ){
13- int num1 = Integer .parseInt (s1 +s2 );
14- int num2 = Integer .parseInt (s2 +s1 );
15-
16- return num2 - num1 ;
9+ public int compare (String a , String b ) {
10+ Integer s1 = Integer .parseInt (a +b );
11+ Integer s2 = Integer .parseInt (b +a );
12+ return s2 - s1 ;
1713 }
18-
1914 });
2015
16+ for (int number : numbers ) {
17+ pq .offer (number +"" );
18+ }
19+
20+ if (pq .peek ().equals ("0" )) return "0" ;
21+
2122 StringBuilder stringBuilder = new StringBuilder ();
22- for ( String str : strList ) {
23- stringBuilder .append (str );
23+ while (! pq . isEmpty ()) {
24+ stringBuilder .append (pq . poll () );
2425 }
25- if ( stringBuilder . toString (). startsWith ( "0" )) return "0" ;
26+
2627 return stringBuilder .toString ();
2728 }
2829}
You can’t perform that action at this time.
0 commit comments