일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 29 | 30 | 31 |
- ip
- socket
- javascript
- 수학
- 자바스크립트
- 문자열
- 프로그래머스
- 가천대
- BFS
- 타입 챌린지
- 크롤링
- Nestjs
- TCP
- dfs
- HTTP
- dp
- typescript
- Node.js
- 프로그래머스 레벨 2
- 소켓
- 레벨 1
- type challenge
- 알고리즘
- Algorithm
- 그래프
- HTTP 완벽 가이드
- 백준
- Crawling
- 타입스크립트
- 쉬운 문제
- Today
- Total
목록Node.js (167)
kakasoo
결코 신나지 않았다. 이게 Cpp였다면 솔직히 10분 안에 풀 자신도 있었다. 오류가 발생했다면 아마 다음과 같을 것이다. 배열에 string과 number를 혼용해서 쓰고 있지 않은가? 배열의 사이즈를 적절하게 하지 않아서 메모리가 초과되지 않았는가? 그냥 통째로 문자열로 다루려고 하지 않았는가? 예컨대, "111"를 키 값으로 저장한다던가... 이렇게 하면 문제가 발생한다. 다른 수, 예컨대 "1111"는 "1"과 "1"과 "11"의 조합인지, 아니면 11이 처음이나 중간에 나오는지 어떻게 구별하는가? 메모리가 꼬인다. const readline = require("readline"); const rl = readline.createInterface({ input: process.stdin, outp..
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
const readline = require("readline"); const rl = readline.createInterface({ input: process.stdin, output: process.stdout, }); rl.on("line", (line) => { if (line === "0") { rl.close(); } main(line); }).on("close", () => { process.exit(); }); /** * * @param {string} line */ const main = (line) => { const numbers = line.split(""); while (numbers.length >= 2) { const pre = numbers.shift(); const bac..
const readline = require("readline"); const rl = readline.createInterface({ input: process.stdin, output: process.stdout, }); rl.on("line", (line) => { main(line); }).on("close", () => { process.exit(); }); /** * * @param {string} line */ const main = (line) => { const numbers = line.split(" ").map(Number); const sum = numbers.map((el) => el * el).reduce((acc, cur) => acc + cur); console.log(sum..
const readline = require("readline"); const input = []; let count = 0; const rl = readline.createInterface({ input: process.stdin, output: process.stdout, }); rl.on("line", (line) => { if (!count) { count = 3 * line; } else { input.push(line); if (input.length % 3 === 0) { main(); } if (input.length === count) { rl.close(); } } }).on("close", () => { process.exit(); }); const main = () => { cons..
const readline = require("readline"); const rl = readline.createInterface({ input: process.stdin, output: process.stdout, }); rl.on("line", (line) => { main(Number(line)); rl.close(); }).on("close", () => { process.exit(); }); const main = (line) => { const DP = new Array(line + 1).fill(0); for (let i = 1; i
node.js로 푼 사람이 별로 없다는 게 참 슬픈 일이다. 자바스크립트로도 문제를 풀 수 있는데... 이 문제에서 주의할 것은 다음과 같다. ( 이 문제를 굳이 node.js로 검색했다면야... ) BigInt를 사용할 것. Cpp에서만 문제가 될 줄 알고 자만했는데, BigInt 때문에 틀린 것이었다. mod를 잊지 말 것. 나누라고 문제에 분명히 나와 있다. 혹시나 map 함수나 fill 등의 Array의 프로토타입 함수로 배열을 반환했다면, 모든 인덱스의 배열이 같은 배열을 가리키게 된다. 이 부분은 자바스크립트의 특성이므로 기억해두자. const readline = require("readline"); const rl = readline.createInterface({ input: process..
const readline = require("readline"); const input = []; const rl = readline.createInterface({ input: process.stdin, output: process.stdout, }); rl.on("line", (line) => { input.push(line); if (input.length === 2) { main("0 " + line); rl.close(); } }).on("close", () => { process.exit(); }); /** * * @param {string} line */ const main = (line) => { const number = input[0]; const prices = line.split(..
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 main = (line) => { console.log( String( line .split(" ") .map(BigInt) .reduce((acc, cur) => acc + cur) ) .split("") .join("") ); };
const readline = require("readline"); const input = []; let count = 0; const rl = readline.createInterface({ input: process.stdin, output: process.stdout, }); rl.on("line", (line) => { if (count === 0) { count = line; return; } if (input.length { process.exit(); }); const main = (l..
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 main = (line) => { line = Number(line); const DP = new Array(line + 1).fill(0); DP[1] = 1; DP[2] = 3; for (let i = 3; i