Skip to content

Commit ffc2cf5

Browse files
imchanyobona1122
authored andcommitted
[imchanyo] 25.01.05 (codingTestStd#12)
* 배열자르기 / 기초 * 배열 원소의 길이 / 기초 * 배열 회전시키기 / 기초 * . * 배열 회전시키기 / 로직추가 / 기초 * 중복된 숫자 개수 / 기초 * 제일 작은 수 제거하기 / 중급 * 행렬의 덧셈 /중급
1 parent ea4a45c commit ffc2cf5

File tree

6 files changed

+89
-0
lines changed

6 files changed

+89
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
function solution(strlist) {
2+
var answer = [];
3+
4+
strlist.forEach((string) => answer.push(string.length));
5+
return answer;
6+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
function solution(arr1, arr2) {
2+
let answer = [];
3+
for (let i = 0; i < arr1.length; i++) {
4+
let newArr = [];
5+
for (let j = 0; j < arr1[0].length; j++) {
6+
newArr.push(arr1[i][j] + arr2[i][j]);
7+
}
8+
answer.push(newArr);
9+
}
10+
11+
return answer;
12+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
function solution(array, n) {
2+
var answer = [];
3+
4+
array.forEach((num) => {
5+
if (num === n) {
6+
answer.push(num);
7+
}
8+
});
9+
10+
return answer.length;
11+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
function solution(arr) {
2+
var answer = [];
3+
4+
if (arr[0] === 10) {
5+
return [-1];
6+
}
7+
8+
for (let i = 0; i < arr.length; i++) {
9+
for (let j = 0; j < arr.length; j++) {
10+
if (arr[i] > arr[j]) {
11+
answer.push(arr[i]);
12+
}
13+
}
14+
}
15+
16+
return [...new Set(answer)];
17+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
function solution(numbers, direction) {
2+
var answer = [...numbers];
3+
4+
if (direction === "right") {
5+
const rightNumbers = answer.pop();
6+
answer.unshift(rightNumbers);
7+
} else if (direction === "left") {
8+
const leftNumbers = answer.shift();
9+
answer.push(leftNumbers);
10+
}
11+
12+
return answer;
13+
}
14+
15+
/* slice 연습하기 */
16+
function solution(numbers, direction) {
17+
if (direction === "right") {
18+
const last = numbers.slice(-1);
19+
const rest = numbers.slice(0, -1);
20+
return [...last, ...rest];
21+
} else if (direction === "left") {
22+
const first = numbers.slice(0, 1);
23+
const rest = numbers.slice(1);
24+
return [...rest, ...first];
25+
}
26+
}
27+
28+
/* splice 연습 */
29+
function solution(numbers, direction) {
30+
if (direction === "right") {
31+
const last = numbers.splice(-1, 1);
32+
numbers.unshift(...last);
33+
} else if (direction === "left") {
34+
const first = numbers.splice(0, 1);
35+
numbers.push(...first);
36+
}
37+
return numbers;
38+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
function solution(numbers, num1, num2) {
2+
var answer = [];
3+
answer = numbers.splice(num1, num2);
4+
return answer;
5+
}

0 commit comments

Comments
 (0)