Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
58dae09
remove smallest number / δ»₯�
JustDevRae Jan 2, 2025
d1ddf64
divisible numbers array / δ»₯�
JustDevRae Jan 2, 2025
8d7fe56
duplicate number count / ζΉ²κ³—οΏ½
JustDevRae Jan 2, 2025
d7f63b0
matrix addition / δ»₯�
JustDevRae Jan 2, 2025
36b4d80
array element length / ζΉ²κ³—οΏ½
JustDevRae Jan 2, 2025
bab0b85
rotate array / ζΉ²κ³—οΏ½
JustDevRae Jan 2, 2025
c8b3d17
slice array / ζΉ²κ³—οΏ½
JustDevRae Jan 2, 2025
45ce6e5
array algorithm md file
JustDevRae Jan 2, 2025
38a1f64
reverse string / 기초
JustDevRae Jan 9, 2025
8219e21
control Z / 기초
JustDevRae Jan 9, 2025
3654602
dart game / 쀑급
JustDevRae Jan 9, 2025
1e2f2b0
valid parentheses / 쀑급
JustDevRae Jan 9, 2025
a4143c9
crane claw game / 쀑급
JustDevRae Jan 9, 2025
ea29442
pull origin JustDevRae branch
JustDevRae Jan 14, 2025
77e2e30
pair count / ζΉ²κ³—οΏ½
JustDevRae Jan 15, 2025
c0967b7
find point position / ζΉ²κ³—οΏ½
JustDevRae Jan 15, 2025
d2dc9af
login success / ζΉ²κ³—οΏ½
JustDevRae Jan 15, 2025
5928dbd
card bundle / δ»₯�
JustDevRae Jan 17, 2025
0d2f982
make hamburger / δ»₯�
JustDevRae Jan 17, 2025
df8ffd4
process / οΏ½Ρ‹οΏ½
JustDevRae Jan 17, 2025
281c961
morse code / ζΉ²κ³—οΏ½
JustDevRae Jan 25, 2025
51c45ac
make B with A / ζΉ²κ³—οΏ½
JustDevRae Jan 25, 2025
40ee840
setting order care / ζΉ²κ³—οΏ½
JustDevRae Jan 25, 2025
f9ab318
not finish runner / δ»₯�
JustDevRae Jan 25, 2025
8f38987
rank order / ζΉ²κ³—οΏ½
JustDevRae Jan 25, 2025
c06f59a
sameTree / ζΉ²κ³—οΏ½
JustDevRae Feb 7, 2025
1a64a0e
invert binary tree / ζΉ²κ³—οΏ½
JustDevRae Feb 7, 2025
77bffa1
maximum depth of binary / ζΉ²κ³—οΏ½
JustDevRae Feb 7, 2025
e28244a
binary tree inorder traversal / ζΉ²κ³—οΏ½
JustDevRae Feb 7, 2025
e500fab
binary tree level order traversal / δ»₯�
JustDevRae Feb 7, 2025
ac894b6
δ»₯났� θ‡Ύλͺ„οΏ½ οΏ½εΈ·κ΅… / ζΉ²κ³—οΏ½
JustDevRae Feb 16, 2025
6ac93fb
οΏ½ θΈ°留 οΏ½κΉ†εͺ“οΏ½ θ‡Ύλͺ„οΏ½ / ζΉ²κ³—οΏ½
JustDevRae Feb 16, 2025
ecd38b3
θ‡ΎλŒοΏ½οΏ½Β¦ζΏ‘ Kεͺ›ι»οΏ½ οΏ½ 戮린 / ζΉ²κ³—οΏ½
JustDevRae Feb 16, 2025
158e9b7
οΏ½οΏ½λͺ„ξ‘”οΏ½οΏ½ / δ»₯�
JustDevRae Feb 16, 2025
06e315f
Contains Duplicate / ζΉ²κ³—οΏ½
JustDevRae Feb 16, 2025
0a7e960
ε―ƒοΏ½Β¦ 留 ο§€θ•€β‘£κ΅…η”± / δ»₯�
JustDevRae Feb 22, 2025
4cc360d
οΏ½Β’ε―ƒ οΏ½ξ‘”οΏ½ / δ»₯�
JustDevRae Feb 22, 2025
f59dde8
諛곕 / οΏ½Ρ‹οΏ½
JustDevRae Feb 22, 2025
cf8759b
Find if Path Exists in Graph / ζΉ²κ³—οΏ½
JustDevRae Feb 22, 2025
de11ecd
Find the Town Judge / ζΉ²κ³—οΏ½
JustDevRae Feb 22, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions JustDevRae/Graph/delivery.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
function solution(N, road, K) {
const graph = Array.from({ length: N + 1 }, () => []);
for (const [a, b, c] of road) {
graph[a].push({ node: b, cost: c });
graph[b].push({ node: a, cost: c });
}

const distance = new Array(N + 1).fill(Infinity);
distance[1] = 0;

const visited = new Array(N + 1).fill(false);

for (let i = 1; i <= N; i++) {
let current = -1;

for (let j = 1; j <= N; j++) {
if (!visited[j] && (current === -1 || distance[j] < distance[current])) {
current = j;
}
}

if (current === -1) break;

visited[current] = true;

for (const { node, cost } of graph[current]) {
if (distance[node] > distance[current] + cost) {
distance[node] = distance[current] + cost;
}
}
}
return distance.filter((time) => time <= K).length;
}
25 changes: 25 additions & 0 deletions JustDevRae/Graph/find_if_path_exists_in_graph.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
var validPath = function (n, edges, source, destination) {
const adjacencyList = new Array(n).fill(0).map(() => []);
for (const [nodeA, nodeB] of edges) {
adjacencyList[nodeA].push(nodeB);
adjacencyList[nodeB].push(nodeA);
}

const visitedNodes = new Array(n).fill(false);
const bfsQueue = [source];
visitedNodes[source] = true;

while (bfsQueue.length) {
const currentNode = bfsQueue.shift();
if (currentNode === destination) return true;

for (const adjacentNode of adjacencyList[currentNode]) {
if (!visitedNodes[adjacentNode]) {
visitedNodes[adjacentNode] = true;
bfsQueue.push(adjacentNode);
}
}
}

return false;
};
16 changes: 16 additions & 0 deletions JustDevRae/Graph/find_the_town_judge.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
var findJudge = function (n, trust) {
if (n === 1) return 1;

const trustScore = new Array(n + 1).fill(0);

for (const [a, b] of trust) {
trustScore[a]--;
trustScore[b]++;
}

for (let i = 1; i <= n; i++) {
if (trustScore[i] === n - 1) return i;
}

return -1;
};
30 changes: 30 additions & 0 deletions JustDevRae/Graph/game_map_shortest_distance.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
function solution(maps) {
const n = maps.length;
const m = maps[0].length;

const dx = [0, 0, 1, -1];
const dy = [1, -1, 0, 0];

let queue = [];
queue.push([0, 0]);

while (queue.length) {
const [y, x] = queue.shift();

if (y === n - 1 && x === m - 1) {
return maps[y][x];
}

for (let i = 0; i < 4; i++) {
const ny = y + dy[i];
const nx = x + dx[i];

if (ny >= 0 && ny < n && nx >= 0 && nx < m && maps[ny][nx] === 1) {
maps[ny][nx] = maps[y][x] + 1;
queue.push([ny, nx]);
}
}
}

return -1;
}
17 changes: 17 additions & 0 deletions JustDevRae/Graph/target_number.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
function solution(numbers, target) {
let count = 0;

function DFS(index, currentSum) {
if (index === numbers.length) {
if (currentSum === target) count++;
return;
}

DFS(index + 1, currentSum + numbers[index]);
DFS(index + 1, currentSum - numbers[index]);
}

DFS(0, 0);

return count;
}
21 changes: 21 additions & 0 deletions JustDevRae/Hash/make_B_with_A.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
function solution(before, after) {
var answer = 0;
const beforeCount = {};
const afterCount = {};

for (const char of before) {
beforeCount[char] = (beforeCount[char] || 0) + 1;
}

for (const char of after) {
afterCount[char] = (afterCount[char] || 0) + 1;
}

for (const key in beforeCount) {
if (beforeCount[key] !== afterCount[key]) {
return (answer = 0);
}
}

return (answer = 1);
}
37 changes: 37 additions & 0 deletions JustDevRae/Hash/morse_code.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
function solution(letter) {
var answer = "";
const morse = {
".-": "a",
"-...": "b",
"-.-.": "c",
"-..": "d",
".": "e",
"..-.": "f",
"--.": "g",
"....": "h",
"..": "i",
".---": "j",
"-.-": "k",
".-..": "l",
"--": "m",
"-.": "n",
"---": "o",
".--.": "p",
"--.-": "q",
".-.": "r",
"...": "s",
"-": "t",
"..-": "u",
"...-": "v",
".--": "w",
"-..-": "x",
"-.--": "y",
"--..": "z",
};
const str = letter.split(" ");

for (const s of str) {
answer += morse[s];
}
return answer;
}
21 changes: 21 additions & 0 deletions JustDevRae/Hash/not_finish_runner.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
function solution(participant, completion) {
const obj = {};

for (const p of participant) {
if (obj[p]) {
obj[p] += 1;
} else {
obj[p] = 1;
}
}

for (const c of completion) {
obj[c] -= 1;
}

for (const key in obj) {
if (obj[key] > 0) {
return key;
}
}
}
6 changes: 6 additions & 0 deletions JustDevRae/Hash/rank_order.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
function solution(score) {
const averages = score.map(([english, math]) => (english + math) / 2);
const sortedAverages = [...averages].sort((a, b) => b - a);

return averages.map((avg) => sortedAverages.indexOf(avg) + 1);
}
10 changes: 10 additions & 0 deletions JustDevRae/Hash/setting_order_care.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
function solution(emergency) {
const sorted = [...emergency].sort((a, b) => b - a);
const rankMap = new Map();

sorted.forEach((value, index) => {
rankMap.set(value, index + 1);
});

return emergency.map((value) => rankMap.get(value));
}
15 changes: 15 additions & 0 deletions JustDevRae/Queue/card_bundle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
function solution(cards1, cards2, goal) {
var answer = "";
for (let word of goal) {
if (word == cards1[0]) {
cards1.shift();
} else if (word == cards2[0]) {
cards2.shift();
} else {
answer = "No";
break;
}
}

return (answer = "Yes");
}
10 changes: 10 additions & 0 deletions JustDevRae/Queue/find_point_position.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
function solution(dot) {
var answer = 0;

if (dot[0] > 0 && dot[1] > 0) answer = 1;
if (dot[0] < 0 && dot[1] > 0) answer = 2;
if (dot[0] < 0 && dot[1] < 0) answer = 3;
if (dot[0] > 0 && dot[1] < 0) answer = 4;

return answer;
}
16 changes: 16 additions & 0 deletions JustDevRae/Queue/login_success.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
function solution(id_pw, db) {
var answer = "";
for (let i = 0; i < db.length; i++) {
if (id_pw[0] === db[i][0]) {
if (id_pw[1] === db[i][1]) {
answer = "login";
break;
}
answer = "wrong pw";
break;
} else {
answer = "fail";
}
}
return answer;
}
20 changes: 20 additions & 0 deletions JustDevRae/Queue/make_hamburger.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
function solution(ingredient) {
const burger = [];
let answer = 0;
for (let i of ingredient) {
burger.push(i);

if (
burger.length >= 4 &&
burger[burger.length - 4] === 1 &&
burger[burger.length - 3] === 2 &&
burger[burger.length - 2] === 3 &&
burger[burger.length - 1] === 1
) {
burger.splice(burger.length - 4, 4);
answer++;
}
}

return answer;
}
13 changes: 13 additions & 0 deletions JustDevRae/Queue/pair_count.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
function solution(n) {
var answer = 0;

// 1λΆ€ν„° nκΉŒμ§€ 숫자λ₯Ό 확인
for (let i = 1; i <= n; i++) {
// iκ°€ n의 μ•½μˆ˜μΈμ§€ 확인
if (n % i === 0) {
// iκ°€ n의 μ•½μˆ˜μΈμ§€ 확인
answer++;
}
}
return answer;
}
20 changes: 20 additions & 0 deletions JustDevRae/Queue/process.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
function solution(priorities, location) {
var answer = 0;
const queue = priorities.map((priority, index) => ({ priority, index }));

while (queue.length > 0) {
const current = queue.shift();

const highPriority = queue.some((item) => item.priority > current.priority);

if (highPriority) {
queue.push(current);
} else {
answer++;

if (current.index === location) {
return answer;
}
}
}
}
4 changes: 4 additions & 0 deletions JustDevRae/Set/contains_duplicate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
var containsDuplicate = function (nums) {
const numSet = new Set(nums);
return numSet.size !== nums.length;
};
18 changes: 18 additions & 0 deletions JustDevRae/Set/pick_random_k_numbers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
function solution(arr, k) {
const uniqueSet = new Set();
const result = [];

for (const num of arr) {
if (!uniqueSet.has(num)) {
uniqueSet.add(num);
result.push(num);
}
if (result.length === k) break;
}

while (result.length < k) {
result.push(-1);
}

return result;
}
15 changes: 15 additions & 0 deletions JustDevRae/Set/prime_factorization.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
function solution(n) {
let result = [];
let divisor = 2;

while (n > 1) {
if (n % divisor === 0) {
result.push(divisor);
n /= divisor;
} else {
divisor++;
}
}

return [...new Set(result)];
}
4 changes: 4 additions & 0 deletions JustDevRae/Set/remove_duplicate_chars.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
function solution(my_string) {
var answer = [...new Set(my_string)].join("");
return answer;
}
16 changes: 16 additions & 0 deletions JustDevRae/Set/unique_chars_only.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
function solution(s) {
const charSet = new Set();
const duplicateSet = new Set();

for (const char of s) {
if (charSet.has(char)) {
duplicateSet.add(char);
} else {
charSet.add(char);
}
}

const uniqueChars = [...charSet].filter((char) => !duplicateSet.has(char));

return uniqueChars.sort().join("");
}
Loading
Loading