๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

ํ”„์—” ๊ณต๋ถ€

(151)
[์•Œ๊ณ ๋ฆฌ์ฆ˜ || ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค] ์ฝœ๋ผ์ธ  ์ถ”์ธก function solution(num) { let count = 0; while (num !== 1 && count
[์•Œ๊ณ ๋ฆฌ์ฆ˜ || ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค] ๋ฌธ์ž์—ด ๋‚ด p์™€ y์˜ ๊ฐœ์ˆ˜ function solution(s) { const count = { p: 0, y: 0 }; for (const char of s.toLowerCase()) { char === 'p' && count.p++; char === 'y' && count.y++; } return count.p === count.y || (count.p === 0 && count.y === 0) ? true : false; } count ๋ผ๋Š” obj ๋ฅผ ๋งŒ๋“ค์–ด์„œ p ์™€ y ๋ฅผ ์ฐพ๋Š”๋‹ค. ์ฐพ๋Š” ๋ฌธ์ž๋Š” ์†Œ๋ฌธ์ž๋กœ ํ†ต์ผ์‹œ์ผฐ๋‹ค. count ์˜ p ์™€ y ๊ฐ€ ๊ฐ™๋‹ค๋ฉด ture, ๋‘˜๋‹ค 0 ์ด๋ฉด false ๋ฅผ ์ถœ๋ ฅํ•œ๋‹ค.
[์•Œ๊ณ ๋ฆฌ์ฆ˜ || ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค] ์ˆซ์ž์˜ ํ‘œํ˜„ function solution(n) { let count = 1; if (n == 1) {return 1} for (let i = 1; i
[์•Œ๊ณ ๋ฆฌ์ฆ˜ || ๋ฐฑ์ค€] node JS - 10798 ์„ธ๋กœ ์ฝ๊ธฐ ๊ธฐ์กด ํ•˜๋˜ ๋ฐฉ์‹๊ณผ ๋‹ค๋ฅด๊ฒŒ for ๋ฌธ์„ ๋Œ๋ ค์•ผํ•ด์„œ ์‚ด์ง ํ—ท๊ฐˆ๋ ธ์ง€๋งŒ 1. ์ฃผ์–ด์ง„ ๋ฌธ์ž์—ด์˜ length ๋Š” ๋™์ผํ•˜์ง€ ์•Š๋‹ค. 2. ๊ฐ€์žฅ ๊ธด ๋ฌธ์ž์—ด์˜ length ๋งŒํผ ๋ฐ˜๋ณต๋ฌธ์„ ๋Œ ๋˜, ๋ฌธ์ž๊ฐ€ ์žˆ์„ ๊ฒฝ์šฐ์—๋งŒ result string ์— ๋ถ™์ธ๋‹ค. let input = require('fs').readFileSync('./dev/stdin').toString().trim().split("\n").map(v => v.replace("\r", "")); const loop = Math.max(...input.map(v => v.length)); let result = ""; for (let i = 0; i < loop; i++) { for (let j = 0; j < input.length; j++) { if (inpu..
[์•Œ๊ณ ๋ฆฌ์ฆ˜ || ๋ฐฑ์ค€] node JS 2566 ์ตœ๋Œ“๊ฐ’ ์•„ ๋„๋Œ€์ฒด ์™œ ํ‹€๋ ธ์ง€ ๋ถ„๋ช… ๋งž๋Š”๋ฐ ๋ผ๊ณ  ์ƒ๊ฐํ•˜๋‹ค๊ฐ€ ์งˆ๋ฌธํ•˜๊ธฐ์—์„œ ๋ฐ˜๋ก€๋ฅผ ๋ฐœ๊ฒฌํ–ˆ๋‹ค. let input = require('fs').readFileSync('./dev/stdin').toString().trim().split("\n").map(v => v.replace("\r", "")); let max = 0; let location = "" for (let i = 0; i max) { max = num[j] location = `${i + 1} ${j + 1}` }; } } console.log..
[์•Œ๊ณ ๋ฆฌ์ฆ˜ || ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค] ์‹ ๊ณ  ๊ฒฐ๊ณผ ๋ฐ›๊ธฐ function solution(id_list, report, k) { const reported = new Map(id_list.map(name => [name, 0])); let whomReported = {}; const reportedCount = {}; [...new Set(report)].forEach(couple => { const [์‹ ๊ณ ์ž, ํ”ผ์‹ ๊ณ ์ž] = couple.split(" "); whomReported[ํ”ผ์‹ ๊ณ ์ž] ? whomReported[ํ”ผ์‹ ๊ณ ์ž].push(์‹ ๊ณ ์ž) : whomReported[ํ”ผ์‹ ๊ณ ์ž] = [์‹ ๊ณ ์ž]; reportedCount[ํ”ผ์‹ ๊ณ ์ž] ? reportedCount[ํ”ผ์‹ ๊ณ ์ž]++ : reportedCount[ํ”ผ์‹ ๊ณ ์ž] = 1; }); const ์ •์ง€์œ ์ € = Obj..
[์•Œ๊ณ ๋ฆฌ์ฆ˜ || ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค] ๋‹ฌ๋ฆฌ๊ธฐ ๊ฒฝ์ฃผ function solution(players, callings) { //player ์˜ ๋ฐฐ์—ด -> callings ์˜ ์ˆœ์„œ ์— ํ•ด๋‹นํ•œ๋Š” ์„ ์ˆ˜์™€ ๊ทธ ์•ž์˜ ์„ ์ˆ˜์˜ ๋ฒˆํ˜ธ๋ฅผ ๋ฐ”๊ฟˆ //callings ๋ฅผ foreach ๋กœ ๋ˆ๋‹ค //callings ์— ์ด๋ฆ„์„ players ์—์„œ indexOf ๋กœ ์ฐพ๊ณ , //index-1 ๊ณผ ์ˆœ์„œ๋ฅผ ๋ฐ”๊พผ๋‹ค. => ์ด์ „ ์„ ์ˆ˜๋ฅผ ์ฐพ๊ณ , ๋จผ์ € ์ด๋ฆ„์„ ๋„ฃ๋Š”๋‹ค. callings.forEach(call => { const callIndex = players.findIndex(v => v === call) const fall = players[callIndex - 1]; players[callIndex] = fall; players[callIndex - 1] = call; console.log..
[์•Œ๊ณ ๋ฆฌ์ฆ˜ || ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค] ๊ฐœ์ธ์ •๋ณด ์ˆ˜์ง‘ ์œ ํšจ๊ธฐ๊ฐ„ ์–ด.... ์ฒจ์— ์ž‘์„ฑํ•˜๋˜ ์ฝ”๋“œ์—์„œ ๋‚ ์งœ ๊ณ„์‚ฐ์ด ๋„ˆ๋ฌด ํ—ท๊ฐˆ๋ ค์„œ ๊ณ„์† 2-3๊ฐœ์”ฉ ์ผ€์ด์Šค ์‹คํŒจ๊ฐ€ ๋–ด๋‹ค. function solution(today, termsSt, privacies) { const terms = Object.fromEntries(termsSt.map(t => [t.split(" ")[0], Number(t.split(" ")[1])] )); today = today.split(".").map(Number); return privacies.reduce((acc, p, i) => { let [y, m, d] = p.split(" ")[0].split(".").map(Number); const type = p.split(" ")[1]; let limitDate = Array(3); const su..

728x90
๋ฐ˜์‘ํ˜•