All'alba vincerò

At dawn, I will win!

Algorithm 17

[백준] 11724번: 연결 요소의 개수

🛠️ 문제 11724번: 연결 요소의 개수  💡 풀이const fs = require('fs');const path = require('path');const input = fs.readFileSync(path.join(__dirname, 'input.txt')).toString().trim().split('\n')const [n, m] = input[0].split(' ').map(Number); // n: 노드 수, m: 간선 수const graph = Array.from({ length: n + 1 }, () => []); // 노드끼리 연결된 정보를 저장할 인접 리스트// - 노드 번호가 1부터 시작하기 때문에 length: n + 1// 그래프 구축for (let i = 1; i { //..

Algorithm 2024.10.08

[백준] 1260번: DFS와 BFS

🛠️ 문제  1260번: DFS와 BFS  💡 풀이const fs = require('fs');const path = require('path');const input = fs.readFileSync(path.join(__dirname, 'input.txt')).toString().trim().split('\n');// 입력 받기const [N, M, V] = input[0].split(' ').map(Number);const graph = Array.from({ length: N + 1 }, () => []); // 정점의 개수만큼 배열 생성for (let i = 1; i adjList.sort((a, b) => a - b));// DFS 함수 (재귀적 방식)const dfs = (start, v..

Algorithm 2024.10.07

[백준] 9093번: 단어 뒤집기

🛠️ 문제 9093번: 단어 뒤집기  💡 풀이const fs = require('fs');const path = require('path');const input = fs.readFileSync(path.join(__dirname, 'input.txt')).toString().trim().split('\n');// ['I am happy today', 'We want to win the first prize']// input의 각 줄을 하나씩 처리하는 함수const result = input.slice(1).map(line => { // 첫 번째 줄을 제외한 나머지 줄 처리 // line은 현재 처리하고 있는 줄 const reversedWords = line.split(' ').map(w..

Algorithm 2024.10.05

[백준] 1966번: 프린터 큐

🛠️ 문제 11066번: 프린터 큐  💡 풀이const fs = require('fs');const path = require('path');const input = fs.readFileSync(path.join(__dirname, 'input.txt')).toString().trim().split('\n');// 배열 분해let [n, ...arr] = input; // n은 테스트 수, 나머지는 테스트 정보// 문자열 배열을 숫자 배열로 변환arr = arr.map((item) => item.split(' ').map(Number));let answer = '';for (let i = 0; i    Algorithm-study/Algorithm/Solving/Stack & Que/1966.js a..

Algorithm 2024.10.04

[백준] 9012번: 괄호

🛠️ 문제 9012번 괄호   💡 풀이const fs = require('fs');const path = require('path');const input = fs.readFileSync(path.join(__dirname, 'input.txt')).toString().trim().split('\n');const len = input.shift(); // input.txt의 첫 번째 요소 (문자열의 개수) 반환const result = [];for (let i = 0; i    Algorithm-study/Algorithm/Solving/Stack & Que/9012.js at main · kwonboryong/Algorithm-study알고리즘(algorithm) 문제 풀이 스터디 . Contrib..

Algorithm 2024.10.03

[백준] 1158번: 요세푸스 문제

✏️ 개념 공부 요세푸스 순열 (Josephus permutation) : 유대인 역사가 플라비우스 요세푸스가 겪은 경험을 바탕으로 만들어진 문제   문제 규칙n명의 사람이 원형으로 앉아있다.첫 번째 사람부터 시작하여 k번째 사람을 제거한다.제거된 다음에는 그 다음 사람부터 다시 k번째 사람을 제거하는 과정을 반복 한 다.이렇게 해서 모든 사람이 제거될 때까지 계속한다.사람들의 제거 순서를 요세푸스 순열이라고 한다.  요세푸스 순열 구하는 방법자료 구조 큐(Queue)를 사용하여 해결할 수 있다.큐는 선입선출(First-In-First-Out, FIFO) 방식으로 동작하며, 사람들을 원형으로 배치하고 제거하는 과정을 큐에서 처리하는 방식이다.   🛠️ 문제 1158번 요세푸스 문제  💡 풀이const..

Algorithm 2024.10.01

[백준] 10828번: 스택

✏️ 개념 공부 스택(stack) Algorithm/Algorithm/CS-Theory/Data-Structures/Stack & Queue.md at main · kwonboryong/Algorithm알고리즘(algorithm) 문제 풀이 스터디 . Contribute to kwonboryong/Algorithm development by creating an account on GitHub.github.com  큐(queue) Algorithm/Algorithm/CS-Theory/Data-Structures/queue.js at main · kwonboryong/Algorithm알고리즘(algorithm) 문제 풀이 스터디 . Contribute to kwonboryong/Algorithm devel..

Algorithm 2024.09.30