ํ์ ๊ณต๋ถ (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.. ์ด์ 1 2 3 4 5 6 ยทยทยท 19 ๋ค์