Skip to content

Commit

Permalink
#13 22.07.02 > 가장 큰 수 다시풀기
Browse files Browse the repository at this point in the history
  • Loading branch information
beurmuz committed Jul 2, 2022
1 parent 71cb4c9 commit 8d41dd8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/programmers/Lv_2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
|6|[숫자의 표현](./expressionNumber.js)|22.06.11|O|X|
|7|[짝지어 제거하기](./mateRemove.js)|22.06.13|O|X|
|8|[프린터](./printer.js)|22.06.24|X|다시풀었다|
|9|[가장 큰 수](./greatestNumber.js)|22.07.01|X|다시|
|9|[가장 큰 수](./greatestNumber.js)|22.07.01|X|O|
11 changes: 11 additions & 0 deletions src/programmers/Lv_2/greatestNumber.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,17 @@ function solution(numbers) {
}


// 22.07.02 다시 풀기
/*
a와 b문자열을 연결해 내림차순으로 정렬한 후 join()
answer[0]이 0인 경우도 처리해주어야 함
*/
function solution(numbers) {
let answer = numbers.sort((a,b) => `${b}${a}` - `${a}${b}`).join('');
return answer[0] === '0' ? '0' : answer;
}



// 다른 풀이보고 변형한 것
function solution(numbers) {
Expand Down

0 comments on commit 8d41dd8

Please sign in to comment.