Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 94bb8a7

Browse files
solve: 2차원으로 만들기
1 parent c64d493 commit 94bb8a7

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

‎Level0/PRO120842.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Solution 1
2+
function solution1(numList, n) {
3+
const twoDimensionalArray = [];
4+
5+
for (let i = 0; i < numList.length; i += n) {
6+
twoDimensionalArray.push(numList.slice(i, i + n));
7+
}
8+
9+
return twoDimensionalArray;
10+
}
11+
12+
// Solution 2
13+
function solution2(numList, n) {
14+
const deepCopiedNumList = [...numList];
15+
16+
return Array(numList.length / n)
17+
.fill([])
18+
.map(() => deepCopiedNumList.splice(0, n));
19+
}

‎README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,3 +297,4 @@
297297
| 23.11.26. | `Level 0` | [삼각형의 완성조건 1](https://school.programmers.co.kr/learn/courses/30/lessons/120889) | [JS](https://github.com/JeongHwan-dev/Algorithm-solving-with-js/blob/master/Level0/PRO120889.js) |
298298
| 23.11.27. | `Level 0` | [순서쌍의 개수](https://school.programmers.co.kr/learn/courses/30/lessons/120836) | [JS](https://github.com/JeongHwan-dev/Algorithm-solving-with-js/blob/master/Level0/PRO120836.js) |
299299
| 23.11.28. | `Level 0` | [분수의 덧셈](https://school.programmers.co.kr/learn/courses/30/lessons/120808) | [JS](https://github.com/JeongHwan-dev/Algorithm-solving-with-js/blob/master/Level0/PRO120808.js) |
300+
| 23.11.29. | `Level 0` | [2차원으로 만들기](https://school.programmers.co.kr/learn/courses/30/lessons/120842) | [JS](https://github.com/JeongHwan-dev/Algorithm-solving-with-js/blob/master/Level0/PRO120842.js) |

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /