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

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

(151)
[์•Œ๊ณ ๋ฆฌ์ฆ˜ || ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค] ํ‚คํŒจ๋“œ ๋ˆ„๋ฅด๊ธฐ, ์ •๊ทœ์‹ test() ํ•จ์ˆ˜ (feat.๋น„๋‚œ๋‹˜์˜ ์ฝ”๋“œ๋ฆฌ๋ทฐ) ์˜ค๋Š˜๋„ ํ•  ์ˆ˜ ์žˆ๋Š” ๊ฒƒ๋“ค์„ ์ˆœ์„œ๋Œ€๋กœ ๋จผ์ € ๋‚˜์—ดํ•ด๋ดค๋‹ค. function solution(numbers, hand) { const click = []; const keypad = [ [1, 2, 3], [4, 5, 6], [7, 8, 9], ['*', 0, '#'] ] const findKey = (n) => { let result = []; keypad.forEach((line, i) => { if (line.findIndex(v => v === n) !== -1) { result = [i, line.findIndex(v => v === n)]; return; } }) return result; } let [leftNow, rightNow] = [[3, 0], [3, 2]]; numbers.forEach(..
[์•Œ๊ณ ๋ฆฌ์ฆ˜ || ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค] ํฌ๋ ˆ์ธ ์ธํ˜• ๋ฝ‘๊ธฐ ๊ฒŒ์ž„ ์˜ค๋Š˜์€ ๊ฐ•์˜์—์„œ ๋ฐฐ์šด ๋Œ€๋กœ ๋จผ์ € ์–ด๋–ค๊ฒŒ ์ฃผ์–ด์กŒ๊ณ , ์–ด๋–ค ๊ฑธ ๊ตฌํ•ด์•ผ ํ•˜๋Š”์ง€ ์ •๋ฆฌ๋ฅผ ๋จผ์ € ํ•ด๋‘๊ณ , ๊ทธ ๋‹ค์Œ์— ์–ด๋–ค ๋ฐฉ์‹์œผ๋กœ ๊ตฌํ•ด์•ผ ํ•˜๋Š”์ง€ ์จ๋ดค๋‹ค. ์ด ๊ณผ์ •๋„ ํ…Œ์ŠคํŠธ์˜ ์ผ๋ถ€๋ผ๊ณ  ์ƒ๊ฐํ•˜๊ณ  ์“ฐ๋‹ˆ ๋‹จ๊ณ„๋ณ„๋กœ ์ฐจ๊ทผ์ฐจ๊ทผ ์“ธ ์ˆ˜ ์žˆ์—ˆ๋‹ค. 0. 2์ฐจ์› ๋ฐฐ์—ด๊ณผ 1์ฐจ์› ๋ฐฐ์—ด์ด ์ฃผ์–ด์ง„๋‹ค. / return ํ•˜๋Š” ๊ฑด count ๋œ ์ˆซ์ž 1. 2์ฐจ์› ๋ฐฐ์—ด์—์„œ moves ๋ฐฐ์—ด์˜ ํ–‰ ์ค‘ ๊ฐ€์žฅ ์œ„์— ์žˆ๋Š” ์ˆ˜ ์ค‘ 0 ์ด ์•„๋‹Œ ์ˆ˜ ๋ฅผ ์ฐพ๋Š”๋‹ค. 2. ์ž„์˜์˜ ๋ฐ”๊ตฌ๋‹ˆ array ๋ฅผ ๋งŒ๋“ ๋‹ค. 3. 1๋ฒˆ์—์„œ ์ฐพ์€ 0์ด ์•„๋‹Œ ์ˆ˜๋ฅผ array ์— ๋„ฃ๋Š”๋‹ค. 4. ๋ฐ”๊ตฌ๋‹ˆ์—์„œ ๊ฐ™์€ ์ˆ˜2๊ฐœ๊ฐ€ ์žˆ๋‹ค๋ฉด ์ œ๊ฑฐํ•œ๋‹ค. 5. ์ œ๊ฑฐ ๋œ ์ธํ˜•์˜ ๊ฐœ์ˆ˜๋ฅผ ๊ตฌํ•œ๋‹ค. (์ œ๊ฑฐ๋˜๋Š” ๊ณผ์ •์ด ๋ฐ˜๋ณต๋œ ์ˆ˜ *2 ๋ฅผ ํ•ด๋„ ๋จ) 4๋ฒˆ์€ ๋”ฐ๋กœ ์ง„ํ–‰ํ•˜๋Š” ๊ฒƒ๋ณด๋‹ค 3๋ฒˆ์„ ์ง„ํ–‰ํ•˜๋ฉด์„œ ํ™•์ธํ•˜๋ฉฐ ์ง„ํ–‰ํ•˜๋Š”๊ฒŒ ๋”..
[์•Œ๊ณ ๋ฆฌ์ฆ˜] How do you improve? ๋ฌธ์ œ ํ•ด๊ฒฐ ์ ‘๊ทผ๋ฒ• ์•Œ๊ณ ๋ฆฌ์ฆ˜ ํ’€์ด๋ฅผ ๋‚˜๋ฆ„ ํ•ด์™”์ง€๋งŒ, ์•Œ๊ณ ๋ฆฌ์ฆ˜ ๊ณต๋ถ€๋Š” ๋”ฐ๋กœ ํ•ด๋ณธ์ ์ด ์—†๋‹ค. ๊ทธ๋ž˜์„œ ์ง€๊ธˆ 1๋‹จ๊ณ„ ํ›„๋ฐ˜์œผ๋กœ ๋„˜์–ด๊ฐ€๋Š” ์‹œ์ ์—์„œ ์•Œ๊ณ ๋ฆฌ์ฆ˜์„ ์ œ๋Œ€๋กœ ํ‘ธ๋Š” ๋ฒ•์„ (์ง€๊ธˆ์ด๋ผ๋„) ๋ฐฐ์›Œ๋ณด๊ธฐ๋กœ ํ–ˆ๋‹ค. 1๋‹จ๊ณ„. ๋ฌธ์ œ ์ดํ•ดํ•˜๊ธฐ 1. ๋ฌธ์ œ๋ฅผ ๋‚˜๋งŒ์˜ ์–ธ์–ด๋กœ ํ‘œํ˜„ํ•  ์ˆ˜ ์žˆ๋Š”๊ฐ€? 2. ์–ด๋–ค ์ž๋ฃŒ๊ฐ€ ๋“ค์–ด์˜ค๋Š”๊ฐ€? 3. ๋„์ถœ๋˜์–ด์•ผ ๊ฒฐ๊ณผ๋Š” ๋ฌด์—‡์ธ๊ฐ€? (์ถœ๋ ฅ ๊ฐ’์ด ์–ด๋–ป๊ฒŒ ๋‚˜์™€์•ผ ํ•˜๋Š”๊ฐ€) 4. ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•  ์ถฉ๋ถ„ํ•œ ์ •๋ณด๊ฐ€ ์ฃผ์–ด์กŒ๋Š”๊ฐ€? (์ฃผ์–ด์ง„ ๋ฐ์ดํ„ฐ๋งŒ ๊ฐ€์ง€๊ณ  ์›ํ•˜๋Š” ๊ฐ’์„ ์ถœ๋ ฅํ•  ์ˆ˜ ์žˆ๋Š”๊ฐ€) 5. ๋ฌธ์ œ์˜ ์ผ๋ถ€์ธ ๋ฐ์ดํ„ฐ์˜ ์ค‘์š”ํ•œ ๋ถ€๋ถ„์— ์–ด๋–ป๊ฒŒ ๋ผ๋ฒจ์„ ์ง€์ •ํ•  ์ˆ˜ ์žˆ๋Š”๊ฐ€ => ๋ฌธ์ œ์—์„œ ์ •๋ง ์ค‘์š”ํ•œ ๊ฒƒ์ด ๋ฌด์—‡์ธ๊ฐ€ ์‹ค์ œ๋กœ ๋ฌธ์ œ๋ฅผ ํŒŒ์•…ํ–ˆ๋‹ค๋ฉด, ์˜ˆ์‹œ๋ฅผ 1-2๊ฐœ ๋งŒ๋“ค์–ด๋ณด๊ธฐ. ์‰ฌ์šด ์˜ˆ์‹œ -> ๋ณต์žกํ•œ ์˜ˆ์‹œ Empty inputs, Invaild inputs ์— ๋Œ€ํ•œ ..
[์•Œ๊ณ ๋ฆฌ์ฆ˜ || ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค] ๋Œ€์ถฉ ๋งŒ๋“  ์žํŒ ์Šคํ„ฐ๋””๊ฐ€ 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 ..

728x90
๋ฐ˜์‘ํ˜•