Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
2c03149
배열 자르기 / 기초
oh-chaeyeon Jan 2, 2025
b307f95
배열 원소의 길이 / 기초
oh-chaeyeon Jan 2, 2025
280b794
배열 회전시키기 / 기초
oh-chaeyeon Jan 2, 2025
2465ff2
중복된 숫자 개수 / 기초
oh-chaeyeon Jan 2, 2025
9b120c8
제일 작은 수 제거하기 / 중급
oh-chaeyeon Jan 2, 2025
e54d44a
행렬의 덧셈 / 중급
oh-chaeyeon Jan 2, 2025
7f618bf
나누어 떨어지는 숫자 배열 / 중급
oh-chaeyeon Jan 2, 2025
121d553
행렬의 곱셈 / 심화
oh-chaeyeon Jan 2, 2025
1c9229c
교점에 별 만들기 / 심화
oh-chaeyeon Jan 2, 2025
865c257
n^2 배열 자르기 / 심화
oh-chaeyeon Jan 2, 2025
ea88f07
String Reversal / 기초
oh-chaeyeon Jan 11, 2025
3f26859
Control Z / 기초
oh-chaeyeon Jan 11, 2025
a8c82b3
Hate English / 기초
oh-chaeyeon Jan 11, 2025
4a4f3f2
String Calculation / 기초
oh-chaeyeon Jan 11, 2025
d30a080
Crane Game / 중급
oh-chaeyeon Jan 11, 2025
a560deb
Valid Parentheses / 중급
oh-chaeyeon Jan 11, 2025
7dadd5d
Dart Game / 중급
oh-chaeyeon Jan 11, 2025
b2fdfc6
Rotate Parentheses / 심화
oh-chaeyeon Jan 11, 2025
e00f4cd
Stock Price / 심화
oh-chaeyeon Jan 11, 2025
9bd1415
Delivery Box / 심화
oh-chaeyeon Jan 11, 2025
92aa4e2
Merge branch 'main' into ohchaeyeon
oh-chaeyeon Jan 11, 2025
8b3840d
순서쌍의 개수 / 기초
oh-chaeyeon Jan 16, 2025
071e7cc
점의 위치 구하기 / 기초
oh-chaeyeon Jan 16, 2025
5b02168
로그인 성공? / 기초
oh-chaeyeon Jan 16, 2025
a358d28
특이한 정렬 / 기초
oh-chaeyeon Jan 16, 2025
d0819a1
카드 뭉치 / 중급
oh-chaeyeon Jan 18, 2025
420da51
공원 산책 / 중급
oh-chaeyeon Jan 18, 2025
f4bc768
햄버거 만들기 / 중급
oh-chaeyeon Jan 18, 2025
c6c4400
Merge branch 'main' into ohchaeyeon
oh-chaeyeon Jan 18, 2025
5815b69
모스부호1 / 기초
oh-chaeyeon Jan 27, 2025
474e842
A로 B만들기 / 기초
oh-chaeyeon Jan 27, 2025
c726708
진로 순서 정하기 / 기초
oh-chaeyeon Jan 27, 2025
e30e7d6
등수 매기기 / 기초
oh-chaeyeon Jan 27, 2025
a8d94b1
완주하지 못한 선수 / 중급
oh-chaeyeon Jan 27, 2025
e27c3a9
포켓몬 / 중급
oh-chaeyeon Jan 27, 2025
d2301ff
추억 점수 / 중급
oh-chaeyeon Jan 27, 2025
16b93e3
할인 행사 / 심화
oh-chaeyeon Jan 27, 2025
4b3f8ee
오픈채팅방 / 심화
oh-chaeyeon Jan 27, 2025
947ecc7
Merge branch 'main' into ohchaeyeon
oh-chaeyeon Jan 27, 2025
e4cfdac
Merge branch 'main' into ohchaeyeon
oh-chaeyeon Feb 10, 2025
eba0569
Maximum Depth of Binary Tree / 초급
oh-chaeyeon Feb 10, 2025
d4d1840
Binary Tree Inorder Traversal / 초급
oh-chaeyeon Feb 10, 2025
1602133
Same Tree / 초급
oh-chaeyeon Feb 10, 2025
648f832
Invert Binary Tree / 초급
oh-chaeyeon Feb 10, 2025
94cfe6d
Binary Tree Level Order Traversal / 중급
oh-chaeyeon Feb 10, 2025
98fa450
Validate Binary Search Tree / 중급
oh-chaeyeon Feb 10, 2025
c2ef4b3
Construct Binary Tree from Preorder and Inorder Traversal / 중급
oh-chaeyeon Feb 10, 2025
8228c60
이진 변환 반복하기 / 심화
oh-chaeyeon Feb 10, 2025
de828da
Binary Tree Maximum Path Sum / 심화
oh-chaeyeon Feb 10, 2025
3014876
Merge branch 'main' into ohchaeyeon
oh-chaeyeon Feb 13, 2025
7817495
Find the Town Judge / 기초
oh-chaeyeon Feb 20, 2025
8dcfb92
Find if Path Exists in Graph / 기초
oh-chaeyeon Feb 20, 2025
4cf5fdf
Find Center of Star Graph / 기초
oh-chaeyeon Feb 20, 2025
9f47b9b
게임 맵 최단거리 / 중급
oh-chaeyeon Feb 20, 2025
ddfb81f
타겟 넘버 / 중급
oh-chaeyeon Feb 20, 2025
0016a9a
전력망을 둘로 나누기 / 심화
oh-chaeyeon Feb 20, 2025
4e37e37
배달 / 심화
oh-chaeyeon Feb 20, 2025
f60c8eb
Merge branch 'main' into ohchaeyeon
oh-chaeyeon Feb 20, 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
9 changes: 9 additions & 0 deletions oh-chaeyeon/7주차_그래프/Find_Center_of_Star_Graph.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* @param {number[][]} edges
* @return {number}
*/
var findCenter = function (edges) {
return edges[0][0] === edges[1][0] || edges[0][0] === edges[1][1]
? edges[0][0]
: edges[0][1];
};
32 changes: 32 additions & 0 deletions oh-chaeyeon/7주차_그래프/Find_if_Path_Exists_in_Graph.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* @param {number} n
* @param {number[][]} edges
* @param {number} source
* @param {number} destination
* @return {boolean}
*/
var validPath = function (n, edges, source, destination) {
const graph = Array.from({ length: n }, () => []);

edges.forEach(([u, v]) => {
graph[u].push(v);
graph[v].push(u);
});

const visited = new Set();

const dfs = (node) => {
if (node === destination) return true;
visited.add(node);

for (const neighbor of graph[node]) {
if (!visited.has(neighbor) && dfs(neighbor)) {
return true;
}
}

return false;
};

return dfs(source);
};
21 changes: 21 additions & 0 deletions oh-chaeyeon/7주차_그래프/Find_the_Town_Judge.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* @param {number} n
* @param {number[][]} trust
* @return {number}
*/
var findJudge = function (n, trust) {
const trustCount = new Array(n + 1).fill(0);

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

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

return -1;
};
45 changes: 45 additions & 0 deletions oh-chaeyeon/7주차_그래프/게임_맵_최단거리.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
function solution(maps) {
const n = maps.length;
const m = maps[0].length;
const directions = [
[1, 0],
[-1, 0],
[0, 1],
[0, -1],
];
const queue = [[0, 0]];
const visited = Array.from({ length: n }, () => Array(m).fill(false));
visited[0][0] = true;
let count = 1;

while (queue.length > 0) {
const size = queue.length;
for (let i = 0; i < size; i++) {
const [x, y] = queue.shift();

if (x === n - 1 && y === m - 1) {
return count;
}

for (const [dx, dy] of directions) {
const nx = x + dx;
const ny = y + dy;

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

return -1;
}
31 changes: 31 additions & 0 deletions oh-chaeyeon/7주차_그래프/배달.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
function solution(N, road, K) {
const graph = Array.from({ length: N + 1 }, () => []);

for (const [a, b, c] of road) {
graph[a].push([b, c]);
graph[b].push([a, c]);
}

const distances = Array(N + 1).fill(Infinity);
distances[1] = 0;
const priorityQueue = [[0, 1]];

while (priorityQueue.length > 0) {
const [currentDistance, currentNode] = priorityQueue.shift();

if (currentDistance > distances[currentNode]) {
continue;
}

for (const [neighbor, time] of graph[currentNode]) {
const newDistance = currentDistance + time;
if (newDistance < distances[neighbor]) {
distances[neighbor] = newDistance;
priorityQueue.push([newDistance, neighbor]);
priorityQueue.sort((a, b) => a[0] - b[0]);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

새 원소를 넣을때마다 sort를 진행하는 것 보다는 큐에서 원소를 꺼내기 전에 sort해주는게 더 효율적일 것 같습니다!

}
}
}

return distances.filter((distance) => distance <= K).length;
}
33 changes: 33 additions & 0 deletions oh-chaeyeon/7주차_그래프/전력망을_돌로_나누기.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
function solution(n, wires) {
const graph = Array.from({ length: n + 1 }, () => []);

for (const [v1, v2] of wires) {
graph[v1].push(v2);
graph[v2].push(v1);
}

let minDifference = Number.MAX_VALUE;

const dfs = (node, visited) => {
let count = 1;
visited[node] = true;

for (const neighbor of graph[node]) {
if (!visited[neighbor]) {
count += dfs(neighbor, visited);
}
}

return count;
};

for (const [v1, v2] of wires) {
const visited = Array(n + 1).fill(false);
visited[v1] = true;
const count = dfs(v2, visited);
const difference = Math.abs(count - (n - count));
minDifference = Math.min(minDifference, difference);
}

return minDifference;
}
18 changes: 18 additions & 0 deletions oh-chaeyeon/7주차_그래프/타켓_넘버.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
function solution(numbers, target) {
const dp = new Map();
dp.set(0, 1);

for (const number of numbers) {
const nextDp = new Map();
for (const [sum, count] of dp) {
nextDp.set(sum + number, (nextDp.get(sum + number) || 0) + count);
nextDp.set(sum - number, (nextDp.get(sum - number) || 0) + count);
}
dp.clear();
for (const [sum, count] of nextDp) {
dp.set(sum, count);
}
}

return dp.get(target) || 0;
}
Loading