Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
88a0ea1
solve: 큐 > 문제 15 요세푸스 문제
Leemainsw Jan 27, 2026
701b6f0
solve: 큐 > 문제 16 기능 개발
Leemainsw Jan 27, 2026
55edcd6
solve: 큐 > 문제 17 카드뭉치
Leemainsw Jan 27, 2026
b61f43f
solve: 큐 > 큐 만들어보기
Leemainsw Jan 27, 2026
7fb8ff3
Merge branch 'main' of https://github.com/KNY1005/commit-to-algorithm
Leemainsw Jan 28, 2026
eb957b9
Merge branch 'main' of https://github.com/KNY1005/commit-to-algorithm
Leemainsw Jan 28, 2026
abf8a16
solve: 해시 > 문제 18 두개이 수로 특정값 만들기
Leemainsw Jan 28, 2026
7e13e9c
solve: 해시 > 문제 19 문자열 해싱을 이용한 검색 함수 만들기
Leemainsw Jan 28, 2026
38f2b3d
solve: 해시 > 문제 20 완주하지 못한 선수
Leemainsw Jan 28, 2026
1509453
solve: 해시 > 문제 21 영어 끝말잇기
Leemainsw Jan 28, 2026
c894f9d
solve: 해시 > 문제 22 전화번호 목록
Leemainsw Jan 28, 2026
cb56e69
solve: 해시 > 문제 23 할인행사
Leemainsw Jan 28, 2026
4caf141
solve: 해시 > 문제 18 두개이 수로 특정값 만들기
Leemainsw Jan 28, 2026
8c7ea15
solve: 해시 > 문제 19 문자열 해싱을 이용한 검색 함수 만들기
Leemainsw Jan 28, 2026
b13e49d
solve: 해시 > 문제 20 완주하지 못한 선수
Leemainsw Jan 28, 2026
316f300
solve: 해시 > 문제 21 영어 끝말잇기
Leemainsw Jan 28, 2026
9dc61aa
solve: 해시 > 문제 22 전화번호 목록
Leemainsw Jan 28, 2026
c8b2d9d
solve: 해시 > 문제 23 할인행사
Leemainsw Jan 28, 2026
162ae2a
Merge branch 'main' of github.com:Leemainsw/commit-to-algorithm
Leemainsw Feb 3, 2026
823a1c4
Merge branch 'main' of https://github.com/KNY1005/commit-to-algorithm
Leemainsw Feb 3, 2026
753c70b
solve: 집합 > 문제 33 간단한 유니온 파인드 알고리즘 구현하기
Leemainsw Feb 3, 2026
597010d
solve: 집합 > 문제 34 폰켓몬
Leemainsw Feb 3, 2026
5f3d78b
solve: 집합 > 문제 35 섬 연결하기
Leemainsw Feb 3, 2026
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
function solution(k, operations) {
const parent = Array.from({ length: k }, (_, index) => index);

function find(x) {
if (parent[x] === x) {
return x;
}

return parent[x] = find(parent[x]);
}

function union(x, y) {
const rootX = find(x);
const rootY = find(y);

if (rootX !== rootY) {
if (rootY < rootX) {
parent[rootX] = rootY;
} else {
parent[rootY] = rootX;
}
}
}

for (const [operation, ...args] of operations) {
if (operation === 'u') {
union(...args);
} else if (operation === 'f') {
find(...args);
}
}

// 집합의 개수 세기
return parent.filter((val, idx) => val === idx).length;

}

console.log(solution(3, [['u', 0, 1], ['u', 1, 2], ['f', 2]])) // 1
console.log(solution(4, [['u', 0, 1], ['u', 2, 3], ['f', 0]])) // 2
10 changes: 10 additions & 0 deletions solutions/yesul/0203/[문제34]폰켓몬.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
function solution(nums) {
const max = nums.length / 2;
const types = new Set(nums);

return Math.min(types.size, max);
}

console.log(solution([3, 1, 2, 3])) // 2
console.log(solution([3, 3, 3, 2, 2, 4])) // 3
console.log(solution([3, 3, 3, 2, 2, 2])) // 2
35 changes: 35 additions & 0 deletions solutions/yesul/0203/[문제35]섬연결하기.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
function solution(n, costs) {
const parent = Array.from({ length: n }, (_, i) => i);

function find(x) {
if (parent[x] === x) {
return x;
}

return parent[x] = find(parent[x]);
}

function union(x, y) {
const rootX = find(x);
const rootY = find(y);
if (rootX !== rootY) {
parent[rootY] = rootX;
return true;
}
return false;

}

// 가장 적은 다리 건설 비용
costs.sort((a, b) => a[2] - b[2]);

let total = 0;

for (const [from, to, cost] of costs) {
if (union(from, to)) {
total += cost;
}
}

return total;
}