[Baekjoon] 1389๋ฒˆ ์ผ€๋นˆ ๋ฒ ์ด์ปจ์˜ 6๋‹จ๊ณ„ ๋ฒ•์น™
ยท
๐Ÿ’ฏ CodingTest/BaekJoon
โ–ถ ๋ฌธ์ œ : https://www.acmicpc.net/problem/1389 1389๋ฒˆ: ์ผ€๋นˆ ๋ฒ ์ด์ปจ์˜ 6๋‹จ๊ณ„ ๋ฒ•์น™ ์ฒซ์งธ ์ค„์— ์œ ์ €์˜ ์ˆ˜ N (2 ≤ N ≤ 100)๊ณผ ์นœ๊ตฌ ๊ด€๊ณ„์˜ ์ˆ˜ M (1 ≤ M ≤ 5,000)์ด ์ฃผ์–ด์ง„๋‹ค. ๋‘˜์งธ ์ค„๋ถ€ํ„ฐ M๊ฐœ์˜ ์ค„์—๋Š” ์นœ๊ตฌ ๊ด€๊ณ„๊ฐ€ ์ฃผ์–ด์ง„๋‹ค. ์นœ๊ตฌ ๊ด€๊ณ„๋Š” A์™€ B๋กœ ์ด๋ฃจ์–ด์ ธ ์žˆ์œผ๋ฉฐ, A์™€ B๊ฐ€ ์นœ๊ตฌ๋ผ๋Š” ๋œป www.acmicpc.net โ–ถ ์ฝ”๋“œ : let input = require('fs').readFileSync(`Computer Science/Alogrithms/๋ฐฑ์ค€JS/testCase.txt`).toString().split('\n'); const [n, m] = input[0].split(' ').map(num => parseInt(num)) let kevin..
[Programmers] (Javascript) ์ˆœ์œ„ ๊ฒ€์ƒ‰
ยท
๐Ÿ’ฏ CodingTest/Programmers
https://programmers.co.kr/learn/courses/30/lessons/72412 a-b); data.set(key, temp); } } function solution(info, query) { let answer = []; makeData(info); let keyList = [...data.keys()]; query.map((s) => { s = s.split(' '); let qScore = s.pop(); s= s.filter((element) => {if (element !== '-' && element !== 'and'){return true;}}); let temp = keyList.filter((key) => s.every(word => key.includes(word..
[Programmers] (Javascript) ๋ฉ”๋‰ด ๋ฆฌ๋‰ด์–ผ
ยท
๐Ÿ’ฏ CodingTest/Programmers
https://programmers.co.kr/learn/courses/30/lessons/72411?language=javascript# ์ฝ”๋”ฉํ…Œ์ŠคํŠธ ์—ฐ์Šต - ๋ฉ”๋‰ด ๋ฆฌ๋‰ด์–ผ ๋ ˆ์Šคํ† ๋ž‘์„ ์šด์˜ํ•˜๋˜ ์Šค์นดํ”ผ๋Š” ์ฝ”๋กœ๋‚˜19๋กœ ์ธํ•œ ๋ถˆ๊ฒฝ๊ธฐ๋ฅผ ๊ทน๋ณตํ•˜๊ณ ์ž ๋ฉ”๋‰ด๋ฅผ ์ƒˆ๋กœ ๊ตฌ์„ฑํ•˜๋ ค๊ณ  ๊ณ ๋ฏผํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ๊ธฐ์กด์—๋Š” ๋‹จํ’ˆ์œผ๋กœ๋งŒ ์ œ๊ณตํ•˜๋˜ ๋ฉ”๋‰ด๋ฅผ ์กฐํ•ฉํ•ด์„œ ์ฝ”์Šค์š”๋ฆฌ ํ˜•ํƒœ๋กœ ์žฌ๊ตฌ์„ฑํ•ด์„œ programmers.co.kr โ–ถ ์ฝ”๋“œ : function solution(orders, course) { let answer = []; let data = new Map(); for (const order of orders) { let orderToArr = [...order]; orderToArr = orderToArr.sort(); for (let i..
[Programmers] (Javascript) ์ถ”์„ ํŠธ๋ž˜ํ”ฝ
ยท
๐Ÿ’ฏ CodingTest/Programmers
https://programmers.co.kr/learn/courses/30/lessons/17676#qna count) { count = temp; } } return count; } โ–ถ ๋ฌธ์ œ ํ’€์ด : 1. ์ดˆ๊ธฐ ๊ฐ๊ฐ์˜ ๋กœ๊ทธ ์ •๋ณด ๋ฌธ์ž์—ด๋“ค์— ๋Œ€ํ•ด ์‹œ๊ฐ„์„ ์ดˆ์˜ ๋ˆ„์ ์œผ๋กœ ๋ณ€ํ™˜ํ•œ๋‹ค. - ํ•ด๋‹น ๋ฌธ์ œ์˜ ๊ฒฝ์šฐ ์†Œ์ˆ˜์  ์…‹์งธ์ž๋ฆฌ๊นŒ์ง€ ๋‚˜ํƒ€๋‚˜ ์žˆ๊ธฐ์— 1000์„ ๊ณฑํ•˜์—ฌ ์ •์ˆ˜ํ˜•ํƒœ๋กœ ๋ณ€ํ™˜ํ•œ๋’ค ์‹œ์ž‘์‹œ๊ฐ„๊ณผ ๋์‹œ๊ฐ„์˜ ์ดˆ(second)๋ˆ„์ ๊ฐ’์„ data ๋ฐฐ์—ด์— ์ €์žฅํ–ˆ๋‹ค. 2. ์ด์ œ ํ•ด๋‹น ๊ฐ’๋“ค์„ ์ด์šฉํ•ด ํƒ์ƒ‰ํ•˜์—ฌ 1์ดˆ๋™์•ˆ ์ฒ˜๋ฆฌ๋œ ๋กœ๊ทธ์ˆ˜์˜ ์ตœ๋Œ€๊ฐ’์„ ์ฐพ์•„์•ผํ•˜๋Š”๋ฐ ์ดˆ๊ธฐ ์™„์ „ํƒ์ƒ‰์„ ์ด์šฉํ•ด ๊ตฌํ˜„ํ–ˆ์œผ๋‚˜ ์‹œ๊ฐ„์ดˆ๊ณผ๊ฐ€ ๋‚˜์™”๋‹ค. 3. ์ด๋กœ์ธํ•ด ๋กœ์ง์— ๋ณ€ํ™”๋ฅผ ์ฃผ์–ด์•ผ ํ–ˆ๊ณ , ์ข…๋ฃŒ์‹œ๊ฐ„์„ ๊ธฐ์ค€์œผ๋กœ ์˜ค๋ฆ„์ฐจ์ˆœ๋œ ์ •๋ ฌ๋œ ๋ฐ์ดํ„ฐ(lines)์ž„์— ์ฐฉ์•ˆํ•˜์—ฌ ๊ฐ ๋กœ๊ทธ์˜ ์ข…๋ฃŒ..
[Programmers] (Javascript) ํŠœํ”Œ
ยท
๐Ÿ’ฏ CodingTest/Programmers
https://programmers.co.kr/learn/courses/30/lessons/64065?language=javascript ์ฝ”๋”ฉํ…Œ์ŠคํŠธ ์—ฐ์Šต - ํŠœํ”Œ "{{2},{2,1},{2,1,3},{2,1,3,4}}" [2, 1, 3, 4] "{{1,2,3},{2,1},{1,2,4,3},{2}}" [2, 1, 3, 4] "{{4,2,3},{3},{2,3,4,1},{2,3}}" [3, 2, 4, 1] programmers.co.kr โ–ถ ์ฝ”๋“œ : function solution(s) { var answer = []; var data = new Map(); // ์ž…๋ ฅ์œผ๋กœ ๋“ค์–ด์˜ค๋Š” ๋ฌธ์ž์—ด ํŒŒ์‹ฑ var reg = new RegExp(/[\{\}]/,'g'); s = s.replace(reg, ''); s = s..
[Programmers] (Javascript) ์ˆ˜์‹ ์ตœ๋Œ€ํ™”
ยท
๐Ÿ’ฏ CodingTest/Programmers
https://programmers.co.kr/learn/courses/30/lessons/67257 ์ฝ”๋”ฉํ…Œ์ŠคํŠธ ์—ฐ์Šต - ์ˆ˜์‹ ์ตœ๋Œ€ํ™” IT ๋ฒค์ฒ˜ ํšŒ์‚ฌ๋ฅผ ์šด์˜ํ•˜๊ณ  ์žˆ๋Š” ๋ผ์ด์–ธ์€ ๋งค๋…„ ์‚ฌ๋‚ด ํ•ด์ปคํ†ค ๋Œ€ํšŒ๋ฅผ ๊ฐœ์ตœํ•˜์—ฌ ์šฐ์Šน์ž์—๊ฒŒ ์ƒ๊ธˆ์„ ์ง€๊ธ‰ํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ์ด๋ฒˆ ๋Œ€ํšŒ์—์„œ๋Š” ์šฐ์Šน์ž์—๊ฒŒ ์ง€๊ธ‰๋˜๋Š” ์ƒ๊ธˆ์„ ์ด์ „ ๋Œ€ํšŒ์™€๋Š” ๋‹ค๋ฅด๊ฒŒ ๋‹ค์Œ๊ณผ programmers.co.kr โ–ถ ์ฝ”๋“œ : function solution(expression) { var orders = [ ['*', '+', '-'], ['*', '-', '+'], ['+', '-', '*'], ['+', '*', '-'], ['-', '+', '*'], ['-', '*', '+'], ]; let answer = -1; for (const order of orders..
[Programmers] (Javascript) ๋‰ด์Šค ํด๋Ÿฌ์Šคํ„ฐ๋ง
ยท
๐Ÿ’ฏ CodingTest/Programmers
https://programmers.co.kr/learn/courses/30/lessons/17677 ์ฝ”๋”ฉํ…Œ์ŠคํŠธ ์—ฐ์Šต - [1์ฐจ] ๋‰ด์Šค ํด๋Ÿฌ์Šคํ„ฐ๋ง ๋‰ด์Šค ํด๋Ÿฌ์Šคํ„ฐ๋ง ์—ฌ๋Ÿฌ ์–ธ๋ก ์‚ฌ์—์„œ ์Ÿ์•„์ง€๋Š” ๋‰ด์Šค, ํŠนํžˆ ์†๋ณด์„ฑ ๋‰ด์Šค๋ฅผ ๋ณด๋ฉด ๋น„์Šท๋น„์Šทํ•œ ์ œ๋ชฉ์˜ ๊ธฐ์‚ฌ๊ฐ€ ๋งŽ์•„ ์ •์ž‘ ํ•„์š”ํ•œ ๊ธฐ์‚ฌ๋ฅผ ์ฐพ๊ธฐ๊ฐ€ ์–ด๋ ต๋‹ค. Daum ๋‰ด์Šค์˜ ๊ฐœ๋ฐœ ์—…๋ฌด๋ฅผ ๋งก๊ฒŒ ๋œ ์‹ ์ž…์‚ฌ์› ํŠœ๋ธŒ programmers.co.kr โ–ถ ์ฝ”๋“œ : function divide(p) { let temp = []; let reg = new RegExp(/[a-z][a-z]/); for (let i =0; i < p.length-1; i ++){ var data = p.slice(i,i+2); if (reg.test(data)){ temp.push(data); } } retur..