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

๋ถ„๋ฅ˜ ์ „์ฒด๋ณด๊ธฐ

(230)
[์•Œ๊ณ ๋ฆฌ์ฆ˜ || ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค] ๋Œ€์ถฉ ๋งŒ๋“  ์žํŒ ์Šคํ„ฐ๋””๊ฐ€ 8์‹œ๋ผ ์ผ์–ด๋‚˜์ž๋งˆ์ž ์•Œ๊ณ ๋ฆฌ์ฆ˜ ๋ฌธ์ œ ํ‘ธ๋‹ˆ๊นŒ ์Šฌ์Šฌ ๋จธ๋ฆฌ๊ฐ€ ์•ˆ๋Œ์•„๊ฐ„๋‹ค. function solution(keymap, targets) { const count = {}; for (const key of keymap) { [...key].forEach((char, i) => { if (!count[char]) { count[char] = i + 1; } else { if (count[char] > i) { count[char] = i + 1; } } }) } const result = targets.map(target => { let sum = 0; for (let i = 0; i < target.length; i++) { if (!count[target[i]]) { sum = -1; break; } ..
[์•Œ๊ณ ๋ฆฌ์ฆ˜ || ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค] ์™„์ฃผํ•˜์ง€ ๋ชปํ•œ ์„ ์ˆ˜ ๋ฌธ์ œ ์ž์ฒด๋Š” ์‰ฌ์›Œ๋ณด์˜€์œผ๋‚˜, ๊ทธ๋ž˜ ๊ทธ๋Ÿผ ๊ทธ๋ ‡์ง€! 10๋งŒ..???? ์–ด๋–ป๊ฒŒ ํ•ด์•ผ ๊ฐ„๋‹จํ•˜๊ณ  ์‹œ๊ฐ„๋„ ์ ๊ฒŒ ๊ฑธ๋ฆด๊นŒ.............. includes ๋“ฑ์˜ ๋ฐฐ์—ด์„ ์ „๋ถ€ ํƒ์ƒ‰ํ•˜๊ฑฐ๋‚˜ ์žฌํ• ๋‹น ์‹œํ‚ค๋Š” ๋“ฑ์˜ ๋กœ์ง์€ ์‹œ๊ฐ„์ด ๋„ˆ๋ฌด ์˜ค๋ž˜ ๊ฑธ๋ฆฐ๋‹ค! ๊ฐœ์ˆ˜๋ฅผ ์„ธ์„œ ๋น„๊ตํ•ด๋ณด๊ธฐ๋กœ ํ–ˆ๋‹ค. function solution(participant, completion) { const pCount = {}; participant.map(v => pCount[v] = 0) participant.map(v => pCount[v]++) const cCount = {}; completion.map(v => cCount[v] = 0) completion.map(v => cCount[v]++) for (const name of Object.keys(..
[์•Œ๊ณ ๋ฆฌ์ฆ˜ || ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค] ์™ผ์ชฝ ์˜ค๋ฅธ์ชฝ ํ’€์ด๋ฅผ ์ž˜๋ชป ์ƒ๊ฐํ•ด์„œ ํ‘ธ๋Š”๋ฐ ํ•œ์ฐธ ๊ฑธ๋ ธ๋‹ค. - ํ‹€๋ฆผ function solution(str_list) { const index_l = str_list.findIndex(v => v === "l"); const index_r = str_list.findIndex(v => v === "r"); const lastInd = str_list.length - 1; if (index_l !== -1) { if (index_l index_r) { return index_r === lastInd ? [] : str_list.slice(index_r + 1, la..
[์•Œ๊ณ ๋ฆฌ์ฆ˜ || ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค] ์ฒด์œก๋ณต ์ด๊ฑฐ ํ’€๊ธด ๋‚˜๋ฆ„ ๋นจ๋ฆฌ ํ’€์—ˆ๋Š”๋ฐ, ์ฝ”๋“œ ์ •๋ฆฌํ•˜๋Š” ๊ฑธ ๋ฐฐ์› ๋‹ค. * 2๊ฐœ ์ด์ƒ ๊ฐ€์ง€๊ณ  ์žˆ๋Š” ์•  -> ์˜ค๋ฅธ์ชฝ์œผ๋กœ ์ „๋‹ฌ, * 2๊ฐœ ์ด์ƒ ๊ฐ€์ง€๊ณ  ์žˆ๋Š” ์•  lost.includes(i + 1) ? 0 : 1).map((v, i) => reserve.includes(i + 1) ? v += 1 : v) const upper = (swts) => { for (let i = 0; i 1) { swts[i] += 1; swts[i + 1] -= 1; } } return swts; } const lower = (swts) => { for (let i = 1; i < swts.length; i++) { if (swts[i] ==..
[์•Œ๊ณ ๋ฆฌ์ฆ˜ || ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค] ์˜น์•Œ์ด(2) ์ƒ๊ฐ๊ณผ ๊ณผ์ •์„ ์ž˜ ์ •๋ฆฌํ•˜๊ณ  ํ‘ธ๋Š” ๊ฒŒ ์–ผ๋งˆ๋‚˜ ์ค‘์š”ํ•œ์ง€ ๋˜ ๊นจ๋‹ฌ์•˜๋‹ค. ์–ด์ œ๋Š” ํ’€๋ ค๊ณ  ํ•œ ๋‘์‹œ๊ฐ„ ์ •๋„ ์‹œ๋„ ํ–ˆ๋Š”๋ฐ ํ†ต๊ณผ ๋ชปํ–ˆ๋‹ค. ์—ฐ์†๋œ ๋ฌธ์ž๋Š” ๋งํ•˜์ง€ ๋ชปํ•œ๋‹ค๋Š” ๊ฑธ ๋Šฆ๊ฒŒ ์ธ์‹ํ–ˆ๊ณ , ์–ด๋–ป๊ฒŒ ํŒ๋ณ„ํ•ด์•ผํ•˜๋‚˜ ๋พฐ์กฑํ•œ ์ˆ˜๊ฐ€ ์ƒ๊ฐ๋‚˜์ง€ ์•Š์•˜๋‹ค. (์ด๋ฏธ ์ข€ ์ง€์นจ) ์˜ค๋Š˜์€ ์–ด์ œ ์ฐธ์„ ๋ชปํ•œ ๋น„๋‚œ์ขŒ๊ฐ€ ์–ด์ œ๊บผ ํ‘ผ๋‹ค๊ณ  ํ•˜์…”์„œ ๋‚˜๋„ ๋‹ค์‹œ ์‹œ๋„ํ•ด๋ณด๊ธฐ๋กœ ํ–ˆ๋‹ค. ๊ทธ๋ฆฌ๊ณ  ํ’€์—ˆ๋‹ค!! ์•ผํ˜ธ! function solution(babbling) { const words = ["aya", "ye", "woo", "ma"]; const isSeries = (b, word) => { let s = b.replaceAll(word, "?"); for (let i = 1; i < s.length; i++) { if (s[i] === "?") { if (s[i ..
[์•Œ๊ณ ๋ฆฌ์ฆ˜ || ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค] ์ˆซ์ž ์ง๊ฟ ๋Œ€๋žต์ ์ธ ํ’€์ด๋Š” 30๋ถ„ ์ •๋„ ๋งŒ์— ํ–ˆ๋Š”๋ฐ, ๊ณ„์† ์‹œ๊ฐ„ ์ดˆ๊ณผ๊ฐ€ ๋–ด๋‹ค. 11-15๋Š” BigInt ๊ฐ€ ๋ถ„๋ช…ํ•ด! function solution(X, Y) { const Xcount = new Array(10).fill(0); const Ycount = new Array(10).fill(0); X.split("").map(v => Xcount[+v]++); Y.split("").map(v => Ycount[+v]++); const resultCount = []; for (let i = 0; i i) : Array.from({ length: Yco..
[์•Œ๊ณ ๋ฆฌ์ฆ˜ || ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค] [1์ฐจ] ๋‹คํŠธ ๊ฒŒ์ž„ ๋‹น์—ฐํ•œ ์–˜๊ธฐ์ง€๋งŒ, ๋ฌธ์ œ๋ฅผ ์ž˜ ์ฝ๊ณ  ํŒจํ„ด์„ ๋นจ๋ฆฌ ํŒŒ์•…ํ•ด์•ผ ๋ฌธ์ œ๋ฅผ ๋นจ๋ฆฌ ํ•ด๊ฒฐํ•  ์ˆ˜ ์žˆ๋‹ค.... (ํŠนํžˆ ์กฐ๊ฑด๋“ค์ด ๋ณต์žกํ•  ๋•,,) function solution(dartResult) { const score = dartResult.split(/[^0-9]/).filter(v => v !== "") const result = dartResult.split(/[0-9]/).filter(v => v !== ""); let sumAll = []; result.map((v, i) => { let sum = v[0] == "S" ? score[i] : v[0] == "D" ? score[i] ** 2 : score[i] ** 3; if (!v[1]) { sumAll.push(Number(sum)); } if (v[1] ..
[์•Œ๊ณ ๋ฆฌ์ฆ˜ || ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค] ๋ง์น ํ•˜๊ธฐ ๊ฐˆ ์ˆ˜๋ก ์‹œ๊ฐ„์ด ์—„์ฒญ ๊ฑธ๋ฆฌ๋Š”๋ฐ.. ๊ธฐ๋ถ„ํƒ“์ธ๊ฐ€.... ์ „์— ๋น„์Šทํ•œ ๋ฌธ์ œ ํ’€์—ˆ๋˜๊ฑฐ ๊ฐ™์€๋ฐ, ํ’€๋ฉด์„œ ์—„์ฒญ ํ—ท๊ฐˆ๋ ค์„œ ์• ๋จน์—ˆ๋‹ค... ํ’€ ์ˆ˜ ์žˆ์„ ๊ฑฐ ๊ฐ™์€๋ฐ ์ž˜ ์•ˆ๋ผ์„œ ์˜ค๋ž˜ ์žก๊ณ  ์žˆ์—ˆ๋‹ค. (์˜ค์ „์— 2์‹œ๊ฐ„ ๋ณด๊ณ  ์˜คํ›„์— 1์‹œ๊ฐ„ ๊ฑธ๋ ค์„œ ํ’€์–ด๋ƒˆ๋‹ค,) function solution(n, m, sections) { let allSection = new Array(n + 1).fill(0); Array.from(sections, x => allSection[x] = -1); let count = 0; sections.map(s => { if (allSection[s] === -1) { count++; for (let i = s; i < s + m; i++) { allSection[i] += 1; }; } }) return c..

728x90
๋ฐ˜์‘ํ˜•