자바스크립트

https://www.acmicpc.net/problem/1158코드const fs = require("fs");const filePath = process.platform === "linux" ? "dev/stdin" : "input.txt";const [n, k] = fs .readFileSync(filePath) .toString() .trim() .split(" ") .map((item) => +item);class Node { constructor(value) { this.value = value; this.prev = null; this.next = null; } setPrev(prev) { this.prev = prev; } setNext(next) {..
https://www.acmicpc.net/problem/2178코드const fs = require("fs");const filePath = process.platform === "linux" ? "dev/stdin" : "./input.txt";const input = fs.readFileSync(filePath).toString().trim().split("\n");class Node { constructor(value) { this.value = value; this.next = null; }}class Queue { constructor() { this.head = null; this.tail = null; this.size = 0; } push(value) ..
이 사이트는 자바스크립트 내부의 동작을 시각적으로 보여준다. 자바스크립트를 공부하다 보면 이벤트 루프, 콜 스택 등 말로만 보면 이해가 어려운 개념들도 많았는데 아래 사이트에서 코드를 실행시키고 내부 동작을 살펴보면서 좀 더 쉽게 이해할 수 있을 것 같다.  JS Visualizer 9000 www.jsv9000.app
https://www.acmicpc.net/problem/1260 코드const dfs = (visit_num, visited, now, graph) => { if (visit_num == graph.length) { return; } dfs_path.push(now); // 현재 방문 노드 visited[now] = true; for (const nx of graph[now]) { if (!visited[nx]) { dfs(visit_num + 1, visited, nx, graph); } }};const bfs = (n, graph, start) => { let q = [start]; let visited = new Array(n + 1).fill(false);..
기본 구조가 어느 정도 마련되어 있는 프로그래머스와 달리 백준은 내가 셀프로 입력까지 다 받아야 한다.파이썬할 때는 굉장히 쉬웠는데 자바스크립트는 어려워서 내가 보려고 정리해두는 JS 입력 방법. ✅ 사전 준비우선 node.js와 VSCode는 당연히 설치되어 있어야 한다.그리고 쉽게 실행시켜보기 위해서 VSCode Extension을 하나 깔아준다. 이걸 설치하면 단축키 `Ctrl+Alt+N`으로 쉽게 파일을 실행시킬 수 있다. 실행 중지는 `Ctrl+Alt+M` 이렇게 오른쪽 위에 실행할 수 있는 버튼(▷)도 생기니 이걸 이용해도 된다. ✅ 입력 받아보기const fs = require("fs");const filePath = process.platform === "linux" ? "dev/stdin..
딜레이레이
'자바스크립트' 태그의 글 목록