일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
- Algorithm
- 크롤링
- 레벨 1
- socket
- Crawling
- 자바스크립트
- 프로그래머스 레벨 2
- 타입스크립트
- ip
- 쉬운 문제
- BFS
- Nestjs
- HTTP
- typescript
- 백준
- type challenge
- dp
- 그래프
- javascript
- 문자열
- dfs
- 타입 챌린지
- 가천대
- HTTP 완벽 가이드
- 소켓
- Node.js
- 알고리즘
- 프로그래머스
- TCP
- 수학
- Today
- Total
목록그래프 (12)
kakasoo
const readline = require("readline"); const rl = readline.createInterface({ input: process.stdin, output: process.stdout, }); let N = 0; const input = []; rl.on("line", (line) => { if (!N) { N = Number(line); } else { input.push(line); if (input.length === N - 1) { main(); } } }); const main = () => { const graph = []; const answer = []; for (let i = 1; i { const [from, to] = edge.split(" "); gr..
시간 초과를 해결했더니, 공간 복잡도가 높아지는 문제가 있었다. 일반적으로, dfs로 해서 해결될만한 문제 같은데, 35% 이상을 넘어가면 런타임 에러가 발생했다. ( 중간에 CannotFindModule은 자동완성 때문에 그러하다. ) 내 개인적인 생각으로는, 스택 영역이 고갈되었기 때문이다. 사실, StackSizeExceeded라고 써있으니 당연한 거 아닌가, 생각할 수 있겠지만, 그래도 생각해볼 부분이 나름 있다. 자바스크립트의 변수는 다른 언어들보다 좀 크다. 숫자의 경우의 8바이트, 기본적으로 모든 숫자가 double이기 때문이다. 그러니깐 잘 짜려고 노력해도 남들보다 변수를 2배 이상 가지고 있으니, 똑같은 함수여도 가끔씩 stack이 고갈된다. 따라서 정적인 영역 ( 데이터 영역 )으로 조..
const readline = require("readline"); const rl = readline.createInterface({ input: process.stdin, output: process.stdout, }); const graph = []; let N, M; rl.on("line", (line) => { if (!N) { [N, M] = line.split(" ").map(Number); } else { graph.push(line.split("")); if (graph.length === N) { main(); process.exit(); } } }); const main = () => { let visited = []; const xMove = [0, 0, -1, 1]; const y..
const readline = require("readline"); const rl = readline.createInterface({ input: process.stdin, output: process.stdout, }); const graph = []; let [N, M] = [0, 0]; rl.on("line", (line) => { if (!N) { [N, M] = line.split(" ").map(Number); } else { graph.push(line.split(" ").map(Number)); if (graph.length === N) { main(); process.exit(); } } }); const main = () => { let visited = []; const xMove ..
const readline = require("readline"); const rl = readline.createInterface({ input: process.stdin, output: process.stdout, }); const graph = []; let N, M; rl.on("line", (line) => { if (!N) { [N, M] = line.split(" ").map(Number); } else { const row = line.split(" ").map(Number); graph.push(row); if (graph.length === N) { rl.close(); } } }).on("close", () => { const visited = []; for (let i = 0; i ..
// 백준 2178번 미로 탐색을 풀었습니다. const readline = require("readline"); const rl = readline.createInterface({ input: process.stdin, output: process.stdout, }); let input = []; let N = 0; let M = 0; rl.on("line", (line) => { if (!N) { [N, M] = line.split(" ").map(Number); } else { input.push(line); if (input.length === N) { main(); process.exit(); } } }); const main = () => { const graph = []; const visi..
const readline = require("readline"); const rl = readline.createInterface({ input: process.stdin, output: process.stdout, }); const input = []; let count = 0; rl.on("line", (line) => { if (!count) { count = Number(line); } else { input.push(line); if (input.length === count) { main(); process.exit(); } } }); const main = () => { const graph = []; const visited = []; for (let i = 0; i < count; i+..
// 백준 1707번 이분 그래프를 풀었습니다. const readline = require("readline"); const rl = readline.createInterface({ input: process.stdin, output: process.stdout, }); let count = 0; let input = []; rl.on("line", (line) => { if (!count) { count = Number(line); } else { input.push(line); if (input.length == Number(input[0].split(" ")[1]) + 1) { main(); input = []; } } }); const main = () => { const graph = []; ..
kscodebase.tistory.com/394 이전 문제에 JavaScript에 대한 단점들을 조금 나열했는데, 나름대로 깔끔하게 고쳐보고자 이번에는 중첩된 함수 구조를 사용했다. // 백준 11724번 연결요소의 게수를 풀었습니다. const readline = require("readline"); const rl = readline.createInterface({ input: process.stdin, output: process.stdout, }); const input = []; let N = 0; let M = 0; rl.on("line", (line) => { if (!N) { [N, M] = line.split(" ").map(Number); } else { input.push(line);..
// 백준 1260번 DFS와 BFS를 풀었습니다. const readline = require("readline"); const rl = readline.createInterface({ input: process.stdin, output: process.stdout, }); const input = []; let n = 0; let m = 0; let start = 0; rl.on("line", (line) => { if (!n) { [n, m, start] = line.split(" ").map(Number); } else { input.push(line); if (input.length === m) { main(); process.exit(); } } }); const dfs = (start) =>..
// 백준 13023번 ABCDE를 풀었습니다. const readline = require("readline"); const rl = readline.createInterface({ input: process.stdin, output: process.stdout, }); const input = []; let N = 0; let M = 0; rl.on("line", (line) => { if (!N) { [N, M] = line.split(" ").map(Number); } else { input.push(line); if (input.length === M) { main(); process.exit(); } } }); let visited; let arr; let answer = []; /** * *..
const readline = require("readline"); const rl = readline.createInterface({ input: process.stdin, output: process.stdout, }); rl.on("line", (line) => { main(line); rl.close(); }).on("close", () => { process.exit(); }); const dfs = (cur, max, value) => { if (cur === max) { console.log(value); process.exit(); } if (cur * 2