Skip to content

Commit 8d39ffd

Browse files
authored
[JustDevRae] 25.01.25 (#33)
* remove smallest number / 중급 * divisible numbers array / 중급 * duplicate number count / 기초 * matrix addition / 중급 * array element length / 기초 * rotate array / 기초 * slice array / 기초 * array algorithm md file * reverse string / 기초 * control Z / 기초 * dart game / 중급 * valid parentheses / 중급 * crane claw game / 중급 * pair count / 기초 * find point position / 기초 * login success / 기초 * card bundle / 중급 * make hamburger / 중급 * process / 심화 * morse code / 기초 * make B with A / 기초 * setting order care / 기초 * not finish runner / 중급 * rank order / 기초
1 parent e179ccf commit 8d39ffd

File tree

5 files changed

+95
-0
lines changed

5 files changed

+95
-0
lines changed

JustDevRae/Hash/make_B_with_A.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
function solution(before, after) {
2+
var answer = 0;
3+
const beforeCount = {};
4+
const afterCount = {};
5+
6+
for (const char of before) {
7+
beforeCount[char] = (beforeCount[char] || 0) + 1;
8+
}
9+
10+
for (const char of after) {
11+
afterCount[char] = (afterCount[char] || 0) + 1;
12+
}
13+
14+
for (const key in beforeCount) {
15+
if (beforeCount[key] !== afterCount[key]) {
16+
return (answer = 0);
17+
}
18+
}
19+
20+
return (answer = 1);
21+
}

JustDevRae/Hash/morse_code.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
function solution(letter) {
2+
var answer = "";
3+
const morse = {
4+
".-": "a",
5+
"-...": "b",
6+
"-.-.": "c",
7+
"-..": "d",
8+
".": "e",
9+
"..-.": "f",
10+
"--.": "g",
11+
"....": "h",
12+
"..": "i",
13+
".---": "j",
14+
"-.-": "k",
15+
".-..": "l",
16+
"--": "m",
17+
"-.": "n",
18+
"---": "o",
19+
".--.": "p",
20+
"--.-": "q",
21+
".-.": "r",
22+
"...": "s",
23+
"-": "t",
24+
"..-": "u",
25+
"...-": "v",
26+
".--": "w",
27+
"-..-": "x",
28+
"-.--": "y",
29+
"--..": "z",
30+
};
31+
const str = letter.split(" ");
32+
33+
for (const s of str) {
34+
answer += morse[s];
35+
}
36+
return answer;
37+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
function solution(participant, completion) {
2+
const obj = {};
3+
4+
for (const p of participant) {
5+
if (obj[p]) {
6+
obj[p] += 1;
7+
} else {
8+
obj[p] = 1;
9+
}
10+
}
11+
12+
for (const c of completion) {
13+
obj[c] -= 1;
14+
}
15+
16+
for (const key in obj) {
17+
if (obj[key] > 0) {
18+
return key;
19+
}
20+
}
21+
}

JustDevRae/Hash/rank_order.js

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(([english, math]) => (english + math) / 2);
3+
const sortedAverages = [...averages].sort((a, b) => b - a);
4+
5+
return averages.map((avg) => sortedAverages.indexOf(avg) + 1);
6+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
function solution(emergency) {
2+
const sorted = [...emergency].sort((a, b) => b - a);
3+
const rankMap = new Map();
4+
5+
sorted.forEach((value, index) => {
6+
rankMap.set(value, index + 1);
7+
});
8+
9+
return emergency.map((value) => rankMap.get(value));
10+
}

0 commit comments

Comments
 (0)