본문 바로가기

728x90

Algorithm

[NodeJS] 프로그래머스 주차 요금 계산 const solution = (fees, records) => { const answer = []; const map = {}; const [basicMinutes, basicCost, unitTime, unitCost] = fees; const getMinutes = (hour, minutes) => hour * 60 + minutes; const getCharge = (time) => { let charge = basicCost; time -= basicMinutes; if (0 < time) { charge += Math.ceil(time / unitTime) * unitCost; } return charge; }; for (const record of records) { const [strTim.. 더보기
[NodeJS] 프로그래머스 숫자의 표현 function solution(n) { let answer = n % 2 === 1 ? 2 : 1; let sum = 0; let max = 1; let min = 1; if (n === 1) { return 1; } while (max 더보기
[NodeJS] 백준 6064번 카잉 달력 /** * @link https://www.acmicpc.net/problem/6064 * @name 카잉 달력 */ const readline = require('readline'); const strToNumberArr = (str) => str.split(' ').map(Number); const rl = readline.createInterface({ input: process.stdin, output: process.stdout, }); const input = []; rl.on('line', (line) => { input.push(line); }).on('close', () => { input.shift(); const result = solution(input.map(strToNumberA.. 더보기
[NodeJS] 백준 5525번 IOIOI /** * @link https://www.acmicpc.net/problem/5525 * @name IOIOI */ const readline = require('readline'); const rl = readline.createInterface({ input: process.stdin, output: process.stdout, }); const input = []; rl.on('line', (line) => { input.push(line); }).on('close', () => { const [n, m, s] = input; const result = solution(Number(n), Number(m), s); console.log(result); process.exit(); }); /** *.. 더보기
[NodeJS] 백준 2667번 단지 번호 붙이기 /** * @link https://www.acmicpc.net/problem/2667 * @name 단지번호붙이기 */ const readline = require('readline'); const strToNumberArr = (str) => str.split('').map(Number); const rl = readline.createInterface({ input: process.stdin, output: process.stdout, }); const input = []; rl.on('line', (line) => { input.push(line); }).on('close', () => { const n = Number(input.shift()); const result = solution(n, .. 더보기
[NodeJS] 백준 2178번 미로탐색 /** * @link https://www.acmicpc.net/problem/2178 * @name 미로탐색 */ const readline = require('readline'); const strToNumberArr1 = (str) => str.split(' ').map(Number); const strToNumberArr2 = (str) => str.split('').map(Number); const rl = readline.createInterface({ input: process.stdin, output: process.stdout, }); const input = []; rl.on('line', (line) => { input.push(line); }).on('close', () => { c.. 더보기
[NodeJS] 백준 1992번 쿼드트리 /** * @link https://www.acmicpc.net/problem/1992 * @name 쿼드트리 */ const readline = require('readline'); const strToNumberArr = (str) => str.split('').map(Number); const rl = readline.createInterface({ input: process.stdin, output: process.stdout, }); const input = []; rl.on('line', (line) => { input.push(line); }).on('close', () => { const n = Number(input.shift()); const result = solution(n, inp.. 더보기
[NodeJS] 백준 1697번 /** * @link https://www.acmicpc.net/problem/1697 */ const readline = require('readline'); const strToNumberArr = (str) => str.split(' ').map(Number); const rl = readline.createInterface({ input: process.stdin, output: process.stdout, }); const input = []; rl.on('line', (line) => { input.push(line); }).on('close', () => { const [n, k] = strToNumberArr(input[0]); const result = solution(n, k); con.. 더보기

728x90