Skip to content

Commit

Permalink
2번까지 풀이
Browse files Browse the repository at this point in the history
  • Loading branch information
LKHcoding committed Nov 25, 2024
1 parent 76c5195 commit 2101d0c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/LKHcoding/jsAlgorithmStudy/week01/Summary.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[//]: # ( todo: 요약해서 내용 채워 넣자)
12 changes: 12 additions & 0 deletions src/LKHcoding/jsAlgorithmStudy/week01/배열정렬하기01.js
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]
10 changes: 10 additions & 0 deletions src/LKHcoding/jsAlgorithmStudy/week01/배열제어하기02.js
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 ]

0 comments on commit 2101d0c

Please sign in to comment.