Skip to content

Commit 88c57a3

Browse files
authored
Merge pull request #618 from eric-hjh/main
[황장현] 89차 라이브 코테 제출
2 parents f01946c + 27fa635 commit 88c57a3

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

live8/test89/문제3/황장현.js

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
1-
function compare(a, b) {
2-
if (b.toString()[0] !== a.toString()[0])
3-
return b.toString()[0] - a.toString()[0];
4-
else {
5-
}
6-
}
7-
81
function solution(numbers) {
9-
numbers.sort((a, b) => compare(a, b));
10-
console.log(numbers);
11-
}
2+
numbers = numbers.map(String);
123

4+
numbers.sort((x, y) => (y + x).localeCompare(x + y));
5+
6+
const answer = numbers.join('');
7+
8+
return answer[0] === '0' ? '0' : answer;
9+
}
1310
console.log(solution([6, 10, 2, 11]));
1411
// console.log(solution([3, 30, 34, 5, 9]));

0 commit comments

Comments
 (0)