-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
23 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[//]: # ( todo: 요약해서 내용 채워 넣자) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// 정수 배열을 정렬해서 반환하는 solution( ) 함수를 완성하세요. | ||
|
||
// 제약조건 | ||
// • 정수배열의길이는2이상105이하입니다. | ||
// • 정수배열의각데이터값은- 100,000이상 100,000이하입니다. | ||
|
||
function solution(arr) { | ||
arr.sort((a, b) => a - b); | ||
return arr; | ||
} | ||
|
||
console.log(solution([1, -5, 2, 4, 3])); // [-5, 1, 2, 3, 4] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// 정수배열을하나받습니다. | ||
// 배열의 중복값을 제거하고 | ||
// 배열데이터를 내림차순으로 정렬해서 반환하는 solution() 함수를 구현하세요. | ||
|
||
function solution(arr) { | ||
const result = [...new Set(arr)].sort((a, b) => b - a); | ||
return result; | ||
} | ||
|
||
console.log(solution([4, 2, 2, 1, 3, 4])); // [ 4, 3, 2, 1 ] |