Skip to content

Commit 5d03e2d

Browse files
authored
[oh-chaeyeon] 25.01.23 (#35)
* 배열 자르기 / 기초 * 배열 원소의 길이 / 기초 * 배열 회전시키기 / 기초 * 중복된 숫자 개수 / 기초 * 제일 작은 수 제거하기 / 중급 * 행렬의 덧셈 / 중급 * 나누어 떨어지는 숫자 배열 / 중급 * 행렬의 곱셈 / 심화 * 교점에 별 만들기 / 심화 * n^2 배열 자르기 / 심화 * String Reversal / 기초 * Control Z / 기초 * Hate English / 기초 * String Calculation / 기초 * Crane Game / 중급 * Valid Parentheses / 중급 * Dart Game / 중급 * Rotate Parentheses / 심화 * Stock Price / 심화 * Delivery Box / 심화 * 순서쌍의 개수 / 기초 * 점의 위치 구하기 / 기초 * 로그인 성공? / 기초 * 특이한 정렬 / 기초 * 카드 뭉치 / 중급 * 공원 산책 / 중급 * 햄버거 만들기 / 중급 * 모스부호1 / 기초 * A로 B만들기 / 기초 * 진로 순서 정하기 / 기초 * 등수 매기기 / 기초 * 완주하지 못한 선수 / 중급 * 포켓몬 / 중급 * 추억 점수 / 중급 * 할인 행사 / 심화 * 오픈채팅방 / 심화
1 parent c62bc0a commit 5d03e2d

File tree

9 files changed

+122
-0
lines changed

9 files changed

+122
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
function solution(before, after) {
2+
return before.split("").sort().join("") === after.split("").sort().join("")
3+
? 1
4+
: 0;
5+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
function solution(score) {
2+
const averages = score.map((s) => (s[0] + s[1]) / 2);
3+
const sortedAverages = [...averages].sort((a, b) => b - a);
4+
5+
return averages.map((avg) => sortedAverages.indexOf(avg) + 1);
6+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
function solution(letter) {
2+
const morse = {
3+
".-": "a",
4+
"-...": "b",
5+
"-.-.": "c",
6+
"-..": "d",
7+
".": "e",
8+
"..-.": "f",
9+
"--.": "g",
10+
"....": "h",
11+
"..": "i",
12+
".---": "j",
13+
"-.-": "k",
14+
".-..": "l",
15+
"--": "m",
16+
"-.": "n",
17+
"---": "o",
18+
".--.": "p",
19+
"--.-": "q",
20+
".-.": "r",
21+
"...": "s",
22+
"-": "t",
23+
"..-": "u",
24+
"...-": "v",
25+
".--": "w",
26+
"-..-": "x",
27+
"-.--": "y",
28+
"--..": "z",
29+
};
30+
return letter
31+
.split(" ")
32+
.map((code) => morse[code])
33+
.join("");
34+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
function solution(record) {
2+
const nicknames = {};
3+
const result = [];
4+
5+
record.forEach((entry) => {
6+
const [action, userId, nickname] = entry.split(" ");
7+
if (action !== "Leave") {
8+
nicknames[userId] = nickname;
9+
}
10+
});
11+
12+
record.forEach((entry) => {
13+
const [action, userId] = entry.split(" ");
14+
if (action === "Enter") {
15+
result.push(`${nicknames[userId]}님이 들어왔습니다.`);
16+
} else if (action === "Leave") {
17+
result.push(`${nicknames[userId]}님이 나갔습니다.`);
18+
}
19+
});
20+
21+
return result;
22+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
function solution(participant, completion) {
2+
const count = participant.reduce((acc, name) => {
3+
acc[name] = (acc[name] || 0) + 1;
4+
return acc;
5+
}, {});
6+
7+
completion.forEach((name) => {
8+
count[name]--;
9+
});
10+
11+
return Object.keys(count).find((name) => count[name] > 0);
12+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
function solution(emergency) {
2+
return emergency.map(
3+
(e) => [...emergency].sort((a, b) => b - a).indexOf(e) + 1
4+
);
5+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
function solution(name, yearning, photo) {
2+
return photo.map((p) =>
3+
p.reduce((sum, person) => {
4+
const index = name.indexOf(person);
5+
return sum + (index !== -1 ? yearning[index] : 0);
6+
}, 0)
7+
);
8+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
function solution(nums) {
2+
const newNum = [...new Set(nums)];
3+
const selection = nums.length / 2;
4+
5+
return Math.min(newNum.length, selection);
6+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
function solution(want, number, discount) {
2+
const required = {};
3+
want.forEach((item, index) => {
4+
required[item] = number[index];
5+
});
6+
7+
let day = 0;
8+
9+
for (let i = 0; i <= discount.length - 10; i++) {
10+
const current = {};
11+
12+
for (let j = i; j < i + 10; j++) {
13+
current[discount[j]] = (current[discount[j]] || 0) + 1;
14+
}
15+
16+
const isValid = want.every(
17+
(item) => (current[item] || 0) >= required[item]
18+
);
19+
20+
if (isValid) day++;
21+
}
22+
23+
return day;
24+
}

0 commit comments

Comments
 (0)