[Programmers] (Javascript) ๊ด„ํ˜ธ ๋ณ€ํ™˜
ยท
๐Ÿ’ฏ CodingTest/Programmers
https://programmers.co.kr/learn/courses/30/lessons/60058 ์ฝ”๋”ฉํ…Œ์ŠคํŠธ ์—ฐ์Šต - ๊ด„ํ˜ธ ๋ณ€ํ™˜ ์นด์นด์˜ค์— ์‹ ์ž… ๊ฐœ๋ฐœ์ž๋กœ ์ž…์‚ฌํ•œ "์ฝ˜"์€ ์„ ๋ฐฐ ๊ฐœ๋ฐœ์ž๋กœ๋ถ€ํ„ฐ ๊ฐœ๋ฐœ์—ญ๋Ÿ‰ ๊ฐ•ํ™”๋ฅผ ์œ„ํ•ด ๋‹ค๋ฅธ ๊ฐœ๋ฐœ์ž๊ฐ€ ์ž‘์„ฑํ•œ ์†Œ์Šค ์ฝ”๋“œ๋ฅผ ๋ถ„์„ํ•˜์—ฌ ๋ฌธ์ œ์ ์„ ๋ฐœ๊ฒฌํ•˜๊ณ  ์ˆ˜์ •ํ•˜๋ผ๋Š” ์—…๋ฌด ๊ณผ์ œ๋ฅผ ๋ฐ›์•˜์Šต๋‹ˆ๋‹ค. ์†Œ์Šค๋ฅผ programmers.co.kr โ–ถ ์ฝ”๋“œ : function solution(p) { var answer = ''; answer = recursive(p) return answer; } function recursive(p) { if (p === '') { return ''; } else { let countL = 0; let countR = 0; let u = ''; let v = ''; fo..
[Programmers] (Javascript) ๊ฑฐ๋ฆฌ๋‘๊ธฐ ํ™•์ธํ•˜๊ธฐ
ยท
๐Ÿ’ฏ CodingTest/Programmers
function solution(places) { var answer = []; for(const place of places) { var flag = false; for (var i = 0; i Array(5).fill(false)); //2 ์ฐจ์› ๋ฐฐ์—ด ์ดˆ๊ธฐํ™” ๋ฐ false๋กœ ์ฑ„์šฐ๊ธฐ ์™ธ์›Œ๋‘์ž var q = []; q.push([x, y, 0]) visited[x][y] = true; while (q.length !== 0) { var data = q.shift(); var x = data[0]; var y = data[1]; var d = data[2]; if (d === 2){ continue; } else { for(var i = 0; i=0 && nx=0 && nx
[Programmers] (Javascript) ์˜คํ”ˆ์ฑ„ํŒ…๋ฐฉ
ยท
๐Ÿ’ฏ CodingTest/Programmers
function solution(record) { var answer = []; var idName = new Map(); var cmds = [] for (const reco of record) { var data = reco.split(' '); var cmd = data[0]; var id = data[1]; if (cmd !== 'Change') { cmds.push([cmd,id]); } if (data.length == 3) { idName.set(id, data[2]); } } for (const e of cmds) { if (e[0] === 'Enter'){ answer.push(`${idName.get(e[1])}๋‹˜์ด ๋“ค์–ด์™”์Šต๋‹ˆ๋‹ค.`); } else{ answer.push(`${idNam..
[Programmers] (Javascript) ๋ฌธ์ž์—ด ์••์ถ•
ยท
๐Ÿ’ฏ CodingTest/Programmers
function solution(s) { var answer = 0; var minLenWord = s; var compressed = []; for (var i = 1; i
[Programmers] (Javascript) [1์ฐจ] ๋น„๋ฐ€์ง€๋„
ยท
๐Ÿ’ฏ CodingTest/Programmers
function solution(n, arr1, arr2) { var answer = []; for (var i = 0; i { if (item.length < n){ while (item.length !== n) { item = '0' + item; } } reg0 = new RegExp(/0/,'g'); reg1 = new RegExp(/1/,'g'); item = item.replace(reg0,' '); item = item.replace(reg1,'#'); return item; }); return answer; }
[Programmers] (Javascript) ์‹คํŒจ์œจ
ยท
๐Ÿ’ฏ CodingTest/Programmers
function solution(N, stages) { var answer = []; var result = new Map(); for (num of stages) { if (num > N) { continue; } result.set(num, result.get(num) + 1 || 1); } var count = stages.length; for (var i = 1; i { if (b[1] > a[1]) { return 1; } else if (b[1] == a[1]) { if (a[0] > b[0]) { return 1; } else{ return -1; } } else{ return -1; } })); answer = [...sortedMap.keys()]; return answer; }
[Programmers] (Javascript) ํฌ๋ ˆ์ธ ์ธํ˜•๋ฝ‘๊ธฐ
ยท
๐Ÿ’ฏ CodingTest/Programmers
function solution(board, moves) { var answer = 0; var result = []; for(const e of moves) { var floor = e - 1; for(var i =0; i< board.length; i++) { var data = board[i][floor]; if (data !== 0) { if (result.length === 0) { result.push(data); } else { var trg = result.pop(); if (trg === data) { answer += 2 } else { result.push(trg); result.push(data); } } board[i][floor] = 0; break } } } return ans..