From c55e1562a4479bbaa7fbfacfc6669646254111f3 Mon Sep 17 00:00:00 2001 From: GwonWooL <229861@naver.com> Date: Fri, 23 Jan 2026 16:38:43 +0900 Subject: [PATCH 1/7] =?UTF-8?q?solve:=200123=20=EC=8A=A4=ED=83=9D=208=20~?= =?UTF-8?q?=2013=EB=AC=B8=EC=A0=9C=20=EC=A0=9C=EC=B6=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...35\353\247\236\354\266\224\352\270\260.js" | 15 +++++++++ ...00\355\231\230\355\225\230\352\270\260.js" | 15 +++++++++ ...14\354\240\204\355\225\230\352\270\260.js" | 33 +++++++++++++++++++ ...34\352\261\260\355\225\230\352\270\260.js" | 23 +++++++++++++ ...74\354\213\235\352\260\200\352\262\251.js" | 19 +++++++++++ ...21\352\270\260\352\262\214\354\236\204.js" | 26 +++++++++++++++ 6 files changed, 131 insertions(+) create mode 100644 "solutions/gwonwoo/0123/[\353\254\270\354\240\23408]\352\264\204\355\230\270\354\247\235\353\247\236\354\266\224\352\270\260.js" create mode 100644 "solutions/gwonwoo/0123/[\353\254\270\354\240\23409]10\354\247\204\354\210\230\353\245\2742\354\247\204\354\210\230\353\241\234\353\263\200\355\231\230\355\225\230\352\270\260.js" create mode 100644 "solutions/gwonwoo/0123/[\353\254\270\354\240\23410]\352\264\204\355\230\270\355\232\214\354\240\204\355\225\230\352\270\260.js" create mode 100644 "solutions/gwonwoo/0123/[\353\254\270\354\240\23411]\354\247\235\354\247\200\354\226\264\354\240\234\352\261\260\355\225\230\352\270\260.js" create mode 100644 "solutions/gwonwoo/0123/[\353\254\270\354\240\23412]\354\243\274\354\213\235\352\260\200\352\262\251.js" create mode 100644 "solutions/gwonwoo/0123/[\353\254\270\354\240\23413]\355\201\254\353\240\210\354\235\270\354\235\270\355\230\225\353\275\221\352\270\260\352\262\214\354\236\204.js" diff --git "a/solutions/gwonwoo/0123/[\353\254\270\354\240\23408]\352\264\204\355\230\270\354\247\235\353\247\236\354\266\224\352\270\260.js" "b/solutions/gwonwoo/0123/[\353\254\270\354\240\23408]\352\264\204\355\230\270\354\247\235\353\247\236\354\266\224\352\270\260.js" new file mode 100644 index 0000000..6739bef --- /dev/null +++ "b/solutions/gwonwoo/0123/[\353\254\270\354\240\23408]\352\264\204\355\230\270\354\247\235\353\247\236\354\266\224\352\270\260.js" @@ -0,0 +1,15 @@ +const fs = require('fs'); +let input = fs.readFileSync(0).toString().trim().split(''); + +function solution() { + // 뒤에서부터 순회 (앞에서 지우면 인덱스가 밀리기 때문) + for (let i = input.length - 2; i >= 0; i--) { + if (input[i] === '(' && input[i + 1] === ')') { + // 두 문자를 배열에서 제거 + input.splice(i, 2); + } + } +} +solution(); + +console.log(input.length === 0 ? true : false); diff --git "a/solutions/gwonwoo/0123/[\353\254\270\354\240\23409]10\354\247\204\354\210\230\353\245\2742\354\247\204\354\210\230\353\241\234\353\263\200\355\231\230\355\225\230\352\270\260.js" "b/solutions/gwonwoo/0123/[\353\254\270\354\240\23409]10\354\247\204\354\210\230\353\245\2742\354\247\204\354\210\230\353\241\234\353\263\200\355\231\230\355\225\230\352\270\260.js" new file mode 100644 index 0000000..8c32a89 --- /dev/null +++ "b/solutions/gwonwoo/0123/[\353\254\270\354\240\23409]10\354\247\204\354\210\230\353\245\2742\354\247\204\354\210\230\353\241\234\353\263\200\355\231\230\355\225\230\352\270\260.js" @@ -0,0 +1,15 @@ +const fs = require('fs'); +let num = Number(fs.readFileSync(0).toString()); + +let result = []; +function solution() { + while (num > 0) { + let last = num % 2; + num = Math.floor(num / 2); + result.push(last); + } + // 뒤집어서 올바른 이진수 순서로 변경 + result.reverse(); + console.log(result.join('')); +} +solution(); diff --git "a/solutions/gwonwoo/0123/[\353\254\270\354\240\23410]\352\264\204\355\230\270\355\232\214\354\240\204\355\225\230\352\270\260.js" "b/solutions/gwonwoo/0123/[\353\254\270\354\240\23410]\352\264\204\355\230\270\355\232\214\354\240\204\355\225\230\352\270\260.js" new file mode 100644 index 0000000..31fc3e9 --- /dev/null +++ "b/solutions/gwonwoo/0123/[\353\254\270\354\240\23410]\352\264\204\355\230\270\355\232\214\354\240\204\355\225\230\352\270\260.js" @@ -0,0 +1,33 @@ +function isValid(s) { + let check = []; + for (let i = 0; i < s.length; i++) { + check.push(s[i]); + + // 현재 스택 길이 + let num = check.length; + + if (check[num - 2] === '[' && check[num - 1] === ']') + check.splice(num - 2, 2); + if (check[num - 2] === '{' && check[num - 1] === '}') + check.splice(num - 2, 2); + if (check[num - 2] === '(' && check[num - 1] === ')') + check.splice(num - 2, 2); + } + if (check.length == 0) { + return true; + } +} + +function solution(s) { + let count = 0; + // 문자열을 회전시키면서 검사 + for (let i = 0; i < s.length; i++) { + // 현재 문자열이 올바른 괄호면 카운트 증가 + if (isValid(s)) { + count++; + } + // 문자열을 왼쪽으로 한 칸 회전 + s = s.slice(1) + s[0]; + } + return count; +} diff --git "a/solutions/gwonwoo/0123/[\353\254\270\354\240\23411]\354\247\235\354\247\200\354\226\264\354\240\234\352\261\260\355\225\230\352\270\260.js" "b/solutions/gwonwoo/0123/[\353\254\270\354\240\23411]\354\247\235\354\247\200\354\226\264\354\240\234\352\261\260\355\225\230\352\270\260.js" new file mode 100644 index 0000000..20d0505 --- /dev/null +++ "b/solutions/gwonwoo/0123/[\353\254\270\354\240\23411]\354\247\235\354\247\200\354\226\264\354\240\234\352\261\260\355\225\230\352\270\260.js" @@ -0,0 +1,23 @@ +function solution(s) { + let answer = 0; + + // 짝을 비교하기 위한 스택 배열 + const stack = []; + // 문자열을 배열로 변환 (문자 하나씩 순회하기 위해) + const arr = [...s]; + + for (let chr of arr) { + // 스택이 비어있지 않고, 스택의 마지막 값이 현재 문자와 같다면 + if (stack.length && stack[stack.length - 1] === chr) { + // 짝이므로 제거 + stack.pop(); + } else { + // 짝이 아니면 스택에 추가 + stack.push(chr); + } + } + + stack.length === 0 ? (answer = 1) : (answer = 0); + + return answer; +} diff --git "a/solutions/gwonwoo/0123/[\353\254\270\354\240\23412]\354\243\274\354\213\235\352\260\200\352\262\251.js" "b/solutions/gwonwoo/0123/[\353\254\270\354\240\23412]\354\243\274\354\213\235\352\260\200\352\262\251.js" new file mode 100644 index 0000000..0d1ca3f --- /dev/null +++ "b/solutions/gwonwoo/0123/[\353\254\270\354\240\23412]\354\243\274\354\213\235\352\260\200\352\262\251.js" @@ -0,0 +1,19 @@ +let result = []; +function solution(s) { + for (let i = 0; i < s.length; i++) { + // 현재 기준 가격 + let start = s[i]; + // 가격이 유지된 시간 + let count = 0; + for (let j = i + 1; j < s.length; j++) { + count++; + // 가격이 떨어지면 중단 + if (s[i] > s[j]) { + break; + } + } + // i번째 시점의 유지 시간 저장 + result.push(count); + } + return result; +} diff --git "a/solutions/gwonwoo/0123/[\353\254\270\354\240\23413]\355\201\254\353\240\210\354\235\270\354\235\270\355\230\225\353\275\221\352\270\260\352\262\214\354\236\204.js" "b/solutions/gwonwoo/0123/[\353\254\270\354\240\23413]\355\201\254\353\240\210\354\235\270\354\235\270\355\230\225\353\275\221\352\270\260\352\262\214\354\236\204.js" new file mode 100644 index 0000000..d408f84 --- /dev/null +++ "b/solutions/gwonwoo/0123/[\353\254\270\354\240\23413]\355\201\254\353\240\210\354\235\270\354\235\270\355\230\225\353\275\221\352\270\260\352\262\214\354\236\204.js" @@ -0,0 +1,26 @@ +let cart = []; +function solution(board, moves) { + let answer = 0; + for (let i = 0; i < moves.length; i++) { + let col = moves[i] - 1; + for (let j = 0; j < board.length; j++) { + if (board[j][col] !== 0) { + cart.push(board[j][col]); + board[j][col] = 0; + break; + } + } + } + + const stack = []; + for (let num of cart) { + if (stack.length && stack[stack.length - 1] === num) { + stack.pop(); + answer += 2; + } else { + stack.push(num); + } + } + + return answer; +} From 7c1a8f61965a2c2fa8281e8b59399b69a851dd3c Mon Sep 17 00:00:00 2001 From: GwonWooL <229861@naver.com> Date: Tue, 27 Jan 2026 16:29:03 +0900 Subject: [PATCH 2/7] =?UTF-8?q?solve:=20=EC=8A=A4=ED=83=9D=20>=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=9C=208=20~=20=EB=AC=B8=EC=A0=9C=2012?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...70\354\212\244\353\254\270\354\240\234.js" | 31 +++++++++++++++++ ...60\353\212\245\352\260\234\353\260\234.js" | 33 +++++++++++++++++++ ...64\353\223\234\353\255\211\354\271\230.js" | 18 ++++++++++ 3 files changed, 82 insertions(+) create mode 100644 "solutions/gwonwoo/0127/[\353\254\270\354\240\23415]\354\232\224\354\204\270\355\221\270\354\212\244\353\254\270\354\240\234.js" create mode 100644 "solutions/gwonwoo/0127/[\353\254\270\354\240\23416]\352\270\260\353\212\245\352\260\234\353\260\234.js" create mode 100644 "solutions/gwonwoo/0127/[\353\254\270\354\240\23417]\354\271\264\353\223\234\353\255\211\354\271\230.js" diff --git "a/solutions/gwonwoo/0127/[\353\254\270\354\240\23415]\354\232\224\354\204\270\355\221\270\354\212\244\353\254\270\354\240\234.js" "b/solutions/gwonwoo/0127/[\353\254\270\354\240\23415]\354\232\224\354\204\270\355\221\270\354\212\244\353\254\270\354\240\234.js" new file mode 100644 index 0000000..d9b1ec7 --- /dev/null +++ "b/solutions/gwonwoo/0127/[\353\254\270\354\240\23415]\354\232\224\354\204\270\355\221\270\354\212\244\353\254\270\354\240\234.js" @@ -0,0 +1,31 @@ +const fs = require('fs'); +const input = fs.readFileSync(0).toString().trim().split(' '); + +// n 입력값 +const n = Number(input[0]); +// k 입력값 +const k = Number(input[1]); + +const que = []; +// 1~n이 적혀있는 배열 생성 +for (let i = 1; i <= n; i++) { + que.push(i); +} + +const result = []; // 제거된 순서를 저장할 배열 +let count = 1; +// 큐에 사람이 남아 있을 떄까지 반복 +while (que.length) { + if (count === k) { + // 큐의 맨 앞 사람 제거 + result.push(que.shift()); + count = 1; + } + // k번째 아니면 뒤로 보내기 + else { + que.push(que.shift()); + count++; + } +} + +console.log(`<${result.join(', ')}>`); diff --git "a/solutions/gwonwoo/0127/[\353\254\270\354\240\23416]\352\270\260\353\212\245\352\260\234\353\260\234.js" "b/solutions/gwonwoo/0127/[\353\254\270\354\240\23416]\352\270\260\353\212\245\352\260\234\353\260\234.js" new file mode 100644 index 0000000..4c99577 --- /dev/null +++ "b/solutions/gwonwoo/0127/[\353\254\270\354\240\23416]\352\270\260\353\212\245\352\260\234\353\260\234.js" @@ -0,0 +1,33 @@ +function solution(progresses, speeds) { + // 작업 완료 시간 배열 + const result = []; + // 각 배포마다 몇 개의 기능이 배포되는지 배열 + const answer = []; + // for문을 통해 각 작업당 걸리는 시간 계산 + for (let i = 0; i < progresses.length; i++) { + const num = 100 - progresses[i]; + // 올림으로 반환 + let time = Math.ceil(num / speeds[i]); + result.push(time); + } + + // result 맨 처음 값 저장 + let current = result[0]; + // 자기 자신을 포함함으로 count = 1로 선언 + let count = 1; + for (let i = 1; i < result.length; i++) { + // 현재 값이 뒤 배열 값보다 크면 count++ + if (current >= result[i]) { + count++; + } + // 뒤 배열 값이 크면 그 값을 current로 선언 + else { + answer.push(count); + current = result[i]; + count = 1; + } + } + // 마지막에 해당하는 경우도 포함 + answer.push(count); + return answer; +} diff --git "a/solutions/gwonwoo/0127/[\353\254\270\354\240\23417]\354\271\264\353\223\234\353\255\211\354\271\230.js" "b/solutions/gwonwoo/0127/[\353\254\270\354\240\23417]\354\271\264\353\223\234\353\255\211\354\271\230.js" new file mode 100644 index 0000000..90429b1 --- /dev/null +++ "b/solutions/gwonwoo/0127/[\353\254\270\354\240\23417]\354\271\264\353\223\234\353\255\211\354\271\230.js" @@ -0,0 +1,18 @@ +function solution(a, b, goal) { + // goal 문자열을 문자로 하나씩 전달 + for (let word of goal) { + // 현재 단어가 a의 맨 앞 카드와 같다면 + if (word === a[0]) { + a.shift(); + } + // 현재 단어가 b의 맨 앞 카드와 같다면 + else if (word === b[0]) { + b.shift(); + } + // a, b 어느 쪽에서도 만족하지 않으면 + else { + return 'No'; + } + } + return 'Yes'; +} From ba1533b482cddcf1b9c2d38aaf1b158e4bc50638 Mon Sep 17 00:00:00 2001 From: GwonWooL <229861@naver.com> Date: Wed, 28 Jan 2026 16:16:06 +0900 Subject: [PATCH 3/7] =?UTF-8?q?solve:=20=ED=95=B4=EC=8B=9C=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=9C=2018,=2020?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...52\260\222\353\247\214\353\223\244\352\270\260.js" | 10 ++++++++++ ...54\210\230\353\247\214\353\223\244\352\270\260.js" | 0 ...53\252\273\355\225\234\354\204\240\354\210\230.js" | 11 +++++++++++ ...53\201\235\353\247\220\354\236\207\352\270\260.js" | 0 ...53\262\210\355\230\270\353\252\251\353\241\235.js" | 0 ...55\225\240\354\235\270\355\226\211\354\202\254.js" | 0 6 files changed, 21 insertions(+) create mode 100644 "solutions/gwonwoo/0128/[\353\254\270\354\240\23418]\353\221\220\352\260\234\354\235\230\354\210\230\353\241\234\355\212\271\354\240\225\352\260\222\353\247\214\353\223\244\352\270\260.js" create mode 100644 "solutions/gwonwoo/0128/[\353\254\270\354\240\23419]\353\254\270\354\236\220\354\227\264\355\225\264\354\213\261\354\235\204\354\235\264\354\232\251\355\225\234\352\262\200\354\203\211\355\225\250\354\210\230\353\247\214\353\223\244\352\270\260.js" create mode 100644 "solutions/gwonwoo/0128/[\353\254\270\354\240\23420]\354\231\204\354\243\274\355\225\230\354\247\200\353\252\273\355\225\234\354\204\240\354\210\230.js" create mode 100644 "solutions/gwonwoo/0128/[\353\254\270\354\240\23421]\354\230\201\354\226\264\353\201\235\353\247\220\354\236\207\352\270\260.js" create mode 100644 "solutions/gwonwoo/0128/[\353\254\270\354\240\23422]\354\240\204\355\231\224\353\262\210\355\230\270\353\252\251\353\241\235.js" create mode 100644 "solutions/gwonwoo/0128/[\353\254\270\354\240\23423]\355\225\240\354\235\270\355\226\211\354\202\254.js" diff --git "a/solutions/gwonwoo/0128/[\353\254\270\354\240\23418]\353\221\220\352\260\234\354\235\230\354\210\230\353\241\234\355\212\271\354\240\225\352\260\222\353\247\214\353\223\244\352\270\260.js" "b/solutions/gwonwoo/0128/[\353\254\270\354\240\23418]\353\221\220\352\260\234\354\235\230\354\210\230\353\241\234\355\212\271\354\240\225\352\260\222\353\247\214\353\223\244\352\270\260.js" new file mode 100644 index 0000000..93d5a04 --- /dev/null +++ "b/solutions/gwonwoo/0128/[\353\254\270\354\240\23418]\353\221\220\352\260\234\354\235\230\354\210\230\353\241\234\355\212\271\354\240\225\352\260\222\353\247\214\353\223\244\352\270\260.js" @@ -0,0 +1,10 @@ +function solution(arr, target) { + for (let i = 0; i < arr.length - 1; i++) { + for (let j = i + 1; j < arr.length; j++) { + if (arr[i] + arr[j] === target) { + return true; + } + } + } + return false; +} diff --git "a/solutions/gwonwoo/0128/[\353\254\270\354\240\23419]\353\254\270\354\236\220\354\227\264\355\225\264\354\213\261\354\235\204\354\235\264\354\232\251\355\225\234\352\262\200\354\203\211\355\225\250\354\210\230\353\247\214\353\223\244\352\270\260.js" "b/solutions/gwonwoo/0128/[\353\254\270\354\240\23419]\353\254\270\354\236\220\354\227\264\355\225\264\354\213\261\354\235\204\354\235\264\354\232\251\355\225\234\352\262\200\354\203\211\355\225\250\354\210\230\353\247\214\353\223\244\352\270\260.js" new file mode 100644 index 0000000..e69de29 diff --git "a/solutions/gwonwoo/0128/[\353\254\270\354\240\23420]\354\231\204\354\243\274\355\225\230\354\247\200\353\252\273\355\225\234\354\204\240\354\210\230.js" "b/solutions/gwonwoo/0128/[\353\254\270\354\240\23420]\354\231\204\354\243\274\355\225\230\354\247\200\353\252\273\355\225\234\354\204\240\354\210\230.js" new file mode 100644 index 0000000..23c56c9 --- /dev/null +++ "b/solutions/gwonwoo/0128/[\353\254\270\354\240\23420]\354\231\204\354\243\274\355\225\230\354\247\200\353\252\273\355\225\234\354\204\240\354\210\230.js" @@ -0,0 +1,11 @@ +function solution(participant, completion) { + participant.sort(); // 참가자 이름 정렬 + completion.sort(); // 통과자 이름 정렬 + + for (let i = 0; i < participant.length; i++) { + // 통과하지 못한 딱 한 사람만 출력하기 때문에 정렬했을 때 맞지 않은 사람 출력 + if (participant[i] !== completion[i]) { + return participant[i]; + } + } +} diff --git "a/solutions/gwonwoo/0128/[\353\254\270\354\240\23421]\354\230\201\354\226\264\353\201\235\353\247\220\354\236\207\352\270\260.js" "b/solutions/gwonwoo/0128/[\353\254\270\354\240\23421]\354\230\201\354\226\264\353\201\235\353\247\220\354\236\207\352\270\260.js" new file mode 100644 index 0000000..e69de29 diff --git "a/solutions/gwonwoo/0128/[\353\254\270\354\240\23422]\354\240\204\355\231\224\353\262\210\355\230\270\353\252\251\353\241\235.js" "b/solutions/gwonwoo/0128/[\353\254\270\354\240\23422]\354\240\204\355\231\224\353\262\210\355\230\270\353\252\251\353\241\235.js" new file mode 100644 index 0000000..e69de29 diff --git "a/solutions/gwonwoo/0128/[\353\254\270\354\240\23423]\355\225\240\354\235\270\355\226\211\354\202\254.js" "b/solutions/gwonwoo/0128/[\353\254\270\354\240\23423]\355\225\240\354\235\270\355\226\211\354\202\254.js" new file mode 100644 index 0000000..e69de29 From e3dbb1775a1c7dd1bd5e79dbdf07ed8ce6856964 Mon Sep 17 00:00:00 2001 From: GwonWooL <229861@naver.com> Date: Thu, 29 Jan 2026 17:18:34 +0900 Subject: [PATCH 4/7] =?UTF-8?q?solve=20:=20=ED=95=B4=EC=8B=9C=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=9C=2018=20~=2023=EB=B2=88=20=ED=92=80=EC=9D=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...22\353\247\214\353\223\244\352\270\260.js" | 36 +++++++++++++++++++ ...30\353\247\214\353\223\244\352\270\260.js" | 13 +++++++ ...35\353\247\220\354\236\207\352\270\260.js" | 34 ++++++++++++++++++ ...10\355\230\270\353\252\251\353\241\235.js" | 22 ++++++++++++ ...40\354\235\270\355\226\211\354\202\254.js" | 31 ++++++++++++++++ 5 files changed, 136 insertions(+) diff --git "a/solutions/gwonwoo/0128/[\353\254\270\354\240\23418]\353\221\220\352\260\234\354\235\230\354\210\230\353\241\234\355\212\271\354\240\225\352\260\222\353\247\214\353\223\244\352\270\260.js" "b/solutions/gwonwoo/0128/[\353\254\270\354\240\23418]\353\221\220\352\260\234\354\235\230\354\210\230\353\241\234\355\212\271\354\240\225\352\260\222\353\247\214\353\223\244\352\270\260.js" index 93d5a04..1a5f45b 100644 --- "a/solutions/gwonwoo/0128/[\353\254\270\354\240\23418]\353\221\220\352\260\234\354\235\230\354\210\230\353\241\234\355\212\271\354\240\225\352\260\222\353\247\214\353\223\244\352\270\260.js" +++ "b/solutions/gwonwoo/0128/[\353\254\270\354\240\23418]\353\221\220\352\260\234\354\235\230\354\210\230\353\241\234\355\212\271\354\240\225\352\260\222\353\247\214\353\223\244\352\270\260.js" @@ -8,3 +8,39 @@ function solution(arr, target) { } return false; } +// 이중 for문을 사용함으로 시간복잡도는 O(n^2)가 발생한다. +// 그리고 가독성도 그렇게 좋아보이지 않는다. +// 누구나 쉽게 만들 수 있는 코드 +// =============================================== + +function solution(arr, target) { + const result = []; + for (let num of arr) { + if (result.includes(target - num)) { + return true; + } + // 값을 넣어줘야 다음에 이 값을 사용하는지 판단한다. + set.push(num); + } + return false; +} + +// target - num 값이 arr 배열안에 존재만 파악하는 코드 +// 이중 for문보다 보기 가독성이 높지만, 똑같이 시간복잡도는 O(n^2)가 발생한다. +// .includes 메서드는 내부를 순회함으로 O(n)을 갖는다. +// =============================================== + +function solution(arr, target) { + const set = new Set(); + for (let num of arr) { + if (set.has(target - num)) { + return true; + } + // 값을 넣어줘야 다음에 이 값을 사용하는지 판단한다. + set.add(num); + } + return false; +} +// target - num 값이 arr 배열안에 존재만 파악하는 코드 +// set을 이용하여 가독성도 높이고 시간복잡도도 줄였다. O(n) +// set.has()와 set.add() 둘다 O(1) 시간복잡도를 가진다. diff --git "a/solutions/gwonwoo/0128/[\353\254\270\354\240\23419]\353\254\270\354\236\220\354\227\264\355\225\264\354\213\261\354\235\204\354\235\264\354\232\251\355\225\234\352\262\200\354\203\211\355\225\250\354\210\230\353\247\214\353\223\244\352\270\260.js" "b/solutions/gwonwoo/0128/[\353\254\270\354\240\23419]\353\254\270\354\236\220\354\227\264\355\225\264\354\213\261\354\235\204\354\235\264\354\232\251\355\225\234\352\262\200\354\203\211\355\225\250\354\210\230\353\247\214\353\223\244\352\270\260.js" index e69de29..571f2e1 100644 --- "a/solutions/gwonwoo/0128/[\353\254\270\354\240\23419]\353\254\270\354\236\220\354\227\264\355\225\264\354\213\261\354\235\204\354\235\264\354\232\251\355\225\234\352\262\200\354\203\211\355\225\250\354\210\230\353\247\214\353\223\244\352\270\260.js" +++ "b/solutions/gwonwoo/0128/[\353\254\270\354\240\23419]\353\254\270\354\236\220\354\227\264\355\225\264\354\213\261\354\235\204\354\235\264\354\232\251\355\225\234\352\262\200\354\203\211\355\225\250\354\210\230\353\247\214\353\223\244\352\270\260.js" @@ -0,0 +1,13 @@ +function solution(string, query) { + let answer = []; + + const set = new Set(query); + for (let str of string) { + if (set.has(str)) { + answer.push('True'); + } else { + answer.push('false'); + } + } + return answer; +} diff --git "a/solutions/gwonwoo/0128/[\353\254\270\354\240\23421]\354\230\201\354\226\264\353\201\235\353\247\220\354\236\207\352\270\260.js" "b/solutions/gwonwoo/0128/[\353\254\270\354\240\23421]\354\230\201\354\226\264\353\201\235\353\247\220\354\236\207\352\270\260.js" index e69de29..bd96145 100644 --- "a/solutions/gwonwoo/0128/[\353\254\270\354\240\23421]\354\230\201\354\226\264\353\201\235\353\247\220\354\236\207\352\270\260.js" +++ "b/solutions/gwonwoo/0128/[\353\254\270\354\240\23421]\354\230\201\354\226\264\353\201\235\353\247\220\354\236\207\352\270\260.js" @@ -0,0 +1,34 @@ +function solution(n, words) { + const answer = [0, 0]; // 정답 배열 + const set = new Set(); // 단어 재사용 확인 + + let count = 0; // 단어 인덱스 + let order = 1; // 반복 수 + while (count < words.length) { + if (count === 0) { + // 첫번째 문자일 때 + set.add(words[count]); // set에 해당 문자 저장 + count++; + continue; // 바로 다음 문자 진행 + } + // 문자가 중복이 아니고, 앞사람이 말한 단어의 마지막 문자로 시작하는 단어를 말해는지 확인 + else if (set.has(words[count]) || check(words[count - 1], words[count])) { + answer[0] = (count % n) + 1; // 사람 순번 계산 + answer[1] = order; + break; + } + set.add(words[count]); + count++; + + if (count % n === 0) { + // 로테이션이 돌 때 order++ + order++; + } + } + return answer; +} + +// 앞사람이 말한 단어의 마지막 문자로 시작하는 단어를 말해는지 확인 함수 +function check(a, b) { + return a[a.length - 1] !== b[0] ? true : false; +} diff --git "a/solutions/gwonwoo/0128/[\353\254\270\354\240\23422]\354\240\204\355\231\224\353\262\210\355\230\270\353\252\251\353\241\235.js" "b/solutions/gwonwoo/0128/[\353\254\270\354\240\23422]\354\240\204\355\231\224\353\262\210\355\230\270\353\252\251\353\241\235.js" index e69de29..d801d92 100644 --- "a/solutions/gwonwoo/0128/[\353\254\270\354\240\23422]\354\240\204\355\231\224\353\262\210\355\230\270\353\252\251\353\241\235.js" +++ "b/solutions/gwonwoo/0128/[\353\254\270\354\240\23422]\354\240\204\355\231\224\353\262\210\355\230\270\353\252\251\353\241\235.js" @@ -0,0 +1,22 @@ +function solution(phone) { + phone.sort(); // 문자열 정렬 + for (let i = 0; i < phone.length - 1; i++) { + const a = phone[i]; + const b = phone[i + 1]; + + let count = 0; + let answer = true; + for (let j = 0; j < a.length; j++) { + if (a[j] !== b[j]) { + break; + } + count++; + } + if (count === a.length) { + answer = false; + } + if (!answer) return answer; + } + + return true; +} diff --git "a/solutions/gwonwoo/0128/[\353\254\270\354\240\23423]\355\225\240\354\235\270\355\226\211\354\202\254.js" "b/solutions/gwonwoo/0128/[\353\254\270\354\240\23423]\355\225\240\354\235\270\355\226\211\354\202\254.js" index e69de29..a3c623a 100644 --- "a/solutions/gwonwoo/0128/[\353\254\270\354\240\23423]\355\225\240\354\235\270\355\226\211\354\202\254.js" +++ "b/solutions/gwonwoo/0128/[\353\254\270\354\240\23423]\355\225\240\354\235\270\355\226\211\354\202\254.js" @@ -0,0 +1,31 @@ +function solution(want, number, discount) { + let answer = 0; + const obj = {}; + // 원하는 상품과 수량을 객체로 매핑 + for (let i = 0; i < want.length; i++) { + { + obj[want[i]] = number[i]; + } + } + + // 마트 할인 기간 - 회원 자격 기간 (할인 기간 중 연속된 10일씩 확인) + for (let i = 0; i <= discount.length - 10; i++) { + const temp = { ...obj }; + for (let j = i; j < 10 + i; j++) { + // 해당 상품이 원하는 목록에 있으면 개수 감소 + if (temp[discount[j]]) { + temp[discount[j]]--; + } + } + // // 모든 상품이 조건을 만족했는지 확인 + let result = true; + for (let key in temp) { + if (temp[key] > 0) { + result = false; + } + } + // result 값이 false이면, answer++ + if (result) answer++; + } + return answer; +} From cc755aa3c528f0c832c9bf31f4fd7eeeb5e3b370 Mon Sep 17 00:00:00 2001 From: GwonWooL <229861@naver.com> Date: Fri, 30 Jan 2026 16:24:36 +0900 Subject: [PATCH 5/7] =?UTF-8?q?solve:=20=ED=95=B4=EC=89=AC=20=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=9C=2024=20~=2027=EB=B2=88=20=EB=AC=B8=EC=A0=9C=20?= =?UTF-8?q?=ED=92=80=EC=9D=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...10\354\261\204\355\214\205\353\260\251.js" | 22 ++++++++++++ ...44\355\212\270\354\225\250\353\262\224.js" | 24 +++++++++++++ ...60\352\263\274\353\260\233\352\270\260.js" | 35 +++++++++++++++++++ ...64\353\246\254\353\211\264\354\226\274.js" | 14 ++++++++ 4 files changed, 95 insertions(+) create mode 100644 "solutions/gwonwoo/0129/[\353\254\270\354\240\23424]\354\230\244\355\224\210\354\261\204\355\214\205\353\260\251.js" create mode 100644 "solutions/gwonwoo/0129/[\353\254\270\354\240\23425]\353\262\240\354\212\244\355\212\270\354\225\250\353\262\224.js" create mode 100644 "solutions/gwonwoo/0129/[\353\254\270\354\240\23426]\354\213\240\352\263\240\352\262\260\352\263\274\353\260\233\352\270\260.js" create mode 100644 "solutions/gwonwoo/0129/[\353\254\270\354\240\23427]\353\251\224\353\211\264\353\246\254\353\211\264\354\226\274.js" diff --git "a/solutions/gwonwoo/0129/[\353\254\270\354\240\23424]\354\230\244\355\224\210\354\261\204\355\214\205\353\260\251.js" "b/solutions/gwonwoo/0129/[\353\254\270\354\240\23424]\354\230\244\355\224\210\354\261\204\355\214\205\353\260\251.js" new file mode 100644 index 0000000..f6131de --- /dev/null +++ "b/solutions/gwonwoo/0129/[\353\254\270\354\240\23424]\354\230\244\355\224\210\354\261\204\355\214\205\353\260\251.js" @@ -0,0 +1,22 @@ +function solution(record) { + const answer = []; + const user = {}; + + for (const r of record) { + const [pre, id, nick] = r.split(' '); + // Leave에서는 nick 값이 없음! + if (pre !== 'Leave') user[id] = nick; + } + + for (const r of record) { + const [pre, id] = r.split(' '); + + if (pre === 'Enter') { + answer.push(`${user[id]}님이 들어왔습니다.`); + } else if (pre === 'Leave') { + answer.push(`${user[id]}님이 나갔습니다.`); + } + } + + return answer; +} diff --git "a/solutions/gwonwoo/0129/[\353\254\270\354\240\23425]\353\262\240\354\212\244\355\212\270\354\225\250\353\262\224.js" "b/solutions/gwonwoo/0129/[\353\254\270\354\240\23425]\353\262\240\354\212\244\355\212\270\354\225\250\353\262\224.js" new file mode 100644 index 0000000..fcd6e11 --- /dev/null +++ "b/solutions/gwonwoo/0129/[\353\254\270\354\240\23425]\353\262\240\354\212\244\355\212\270\354\225\250\353\262\224.js" @@ -0,0 +1,24 @@ +function solution(types, plays) { + const answer = []; + + // gpt 도움 받음 + const music = types.reduce((acc, cur, index) => { + // classic, pop이든 새로운 장르가 생긴다면, 배열 생성 (장르별 묶기 때문) + if (!acc[cur]) acc[cur] = []; + acc[cur].push({ id: index, play: plays[index] }); + }, {}); + + // 각 장르별 재생횟수 합계 + const totalSum = {}; + for (const type of types) { + let sum = 0; + for (const m of music[type]) { + sum += m.play; + } + totalSum[type] = sum; + } + + // 여기까지 구현함 + + return answer; +} diff --git "a/solutions/gwonwoo/0129/[\353\254\270\354\240\23426]\354\213\240\352\263\240\352\262\260\352\263\274\353\260\233\352\270\260.js" "b/solutions/gwonwoo/0129/[\353\254\270\354\240\23426]\354\213\240\352\263\240\352\262\260\352\263\274\353\260\233\352\270\260.js" new file mode 100644 index 0000000..cbe690a --- /dev/null +++ "b/solutions/gwonwoo/0129/[\353\254\270\354\240\23426]\354\213\240\352\263\240\352\262\260\352\263\274\353\260\233\352\270\260.js" @@ -0,0 +1,35 @@ +function solution(list, report, k) { + const answer = []; // 각 유저가 받은 결과 메일 수 + + // 동일한 신고는 중복으로 제거 + const set = [...new Set(report)]; + // 각 유저가 신고당한 수 + const user = set.reduce((acc, cur) => { + const [p, r] = cur.split(' '); + acc[r] = (acc[r] || 0) + 1; + return acc; + }, {}); + + // 신고가 k번 이상 당한 사람 확인 + const reported = Object.keys(user).filter((key) => user[key] >= k); + + // 메일 보낼 유저 확인 + const mail = list.reduce((acc, cur) => { + acc[cur] = 0; + return acc; + }, {}); + + // 몇 개의 메일을 받을지 확인 + for (let s of set) { + const [p, r] = s.split(' '); + if (reported.includes(r)) { + mail[p]++; + } + } + + // 객체를 배열로 변환 + for (let user of list) { + answer.push(mail[user]); + } + return answer; +} diff --git "a/solutions/gwonwoo/0129/[\353\254\270\354\240\23427]\353\251\224\353\211\264\353\246\254\353\211\264\354\226\274.js" "b/solutions/gwonwoo/0129/[\353\254\270\354\240\23427]\353\251\224\353\211\264\353\246\254\353\211\264\354\226\274.js" new file mode 100644 index 0000000..8b1a904 --- /dev/null +++ "b/solutions/gwonwoo/0129/[\353\254\270\354\240\23427]\353\251\224\353\211\264\353\246\254\353\211\264\354\226\274.js" @@ -0,0 +1,14 @@ +function solution(orders, course) { + const result = course.reduce((acc, cur, index) => { + if (!acc[cur]) acc[cur] = []; + const order = orders[index]; + for (let i = 0; i < order.length - cur; i++) { + for (let j = 0; j < cur; j++) { + acc[cur].push(); + } + } + return acc; + }, {}); +} + +// 시밤 모르겠다 From 7d7582d606327e16df80978f3cc323cf382ed532 Mon Sep 17 00:00:00 2001 From: GwonWooL <229861@naver.com> Date: Wed, 4 Feb 2026 00:53:31 +0900 Subject: [PATCH 6/7] =?UTF-8?q?refactor:=20=EC=BD=94=EB=93=9C=20=EB=A6=AC?= =?UTF-8?q?=ED=8C=A9=ED=86=A0=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...35\353\247\236\354\266\224\352\270\260.js" | 42 ++++++++--- ...00\355\231\230\355\225\230\352\270\260.js" | 30 +++++--- ...14\354\240\204\355\225\230\352\270\260.js" | 73 ++++++++++++++----- ...34\352\261\260\355\225\230\352\270\260.js" | 40 ++++++---- solutions/gwonwoo/0123/refactoring | 0 ...70\354\212\244\353\254\270\354\240\234.js" | 2 + ...44\355\212\270\354\225\250\353\262\224.js" | 6 +- ...70\353\246\254\354\210\234\355\232\214.js" | 0 ...70\353\246\254\352\265\254\355\230\204.js" | 0 ...01\353\214\200\354\247\204\355\221\234.js" | 0 ...53\354\206\224\355\214\220\353\247\244.js" | 0 ...76\352\270\260\352\262\214\354\236\204.js" | 0 12 files changed, 136 insertions(+), 57 deletions(-) create mode 100644 solutions/gwonwoo/0123/refactoring create mode 100644 "solutions/gwonwoo/0130/[\353\254\270\354\240\23428]\355\212\270\353\246\254\354\210\234\355\232\214.js" create mode 100644 "solutions/gwonwoo/0130/[\353\254\270\354\240\23429]\354\235\264\354\247\204\355\203\220\354\203\211\355\212\270\353\246\254\352\265\254\355\230\204.js" create mode 100644 "solutions/gwonwoo/0130/[\353\254\270\354\240\23430]\354\230\210\354\203\201\353\214\200\354\247\204\355\221\234.js" create mode 100644 "solutions/gwonwoo/0130/[\353\254\270\354\240\23431]\353\213\244\353\213\250\352\263\204\354\271\253\354\206\224\355\214\220\353\247\244.js" create mode 100644 "solutions/gwonwoo/0130/[\353\254\270\354\240\23432]\352\270\270\354\260\276\352\270\260\352\262\214\354\236\204.js" diff --git "a/solutions/gwonwoo/0123/[\353\254\270\354\240\23408]\352\264\204\355\230\270\354\247\235\353\247\236\354\266\224\352\270\260.js" "b/solutions/gwonwoo/0123/[\353\254\270\354\240\23408]\352\264\204\355\230\270\354\247\235\353\247\236\354\266\224\352\270\260.js" index 6739bef..e645156 100644 --- "a/solutions/gwonwoo/0123/[\353\254\270\354\240\23408]\352\264\204\355\230\270\354\247\235\353\247\236\354\266\224\352\270\260.js" +++ "b/solutions/gwonwoo/0123/[\353\254\270\354\240\23408]\352\264\204\355\230\270\354\247\235\353\247\236\354\266\224\352\270\260.js" @@ -1,15 +1,35 @@ -const fs = require('fs'); -let input = fs.readFileSync(0).toString().trim().split(''); +// const fs = require('fs'); +// let input = fs.readFileSync(0).toString().trim().split(''); -function solution() { - // 뒤에서부터 순회 (앞에서 지우면 인덱스가 밀리기 때문) - for (let i = input.length - 2; i >= 0; i--) { - if (input[i] === '(' && input[i + 1] === ')') { - // 두 문자를 배열에서 제거 - input.splice(i, 2); +// function solution() { +// // 뒤에서부터 순회 (앞에서 지우면 인덱스가 밀리기 때문) +// for (let i = input.length - 2; i >= 0; i--) { +// if (input[i] === '(' && input[i + 1] === ')') { +// // 두 문자를 배열에서 제거 +// input.splice(i, 2); +// } +// } +// } +// solution(); + +// console.log(input.length === 0 ? true : false); + +function solution(s) { + // "(" 괄호를 저장할 배열 + const arr = []; + for (let i = 0; i < s.length; i++) { + if (s[i] === '(') { + arr.push(s[i]); + } + // ")" 괄호인 경우 + else if (s[i] === ')') { + // 배열이 비어 있으면 짝이 안 맞으므로 false + if (arr.length === 0) { + return false; + } + // 짝이 맞으면 "(" 괄호 하나 제거 + arr.pop(); } } + return arr.length === 0; } -solution(); - -console.log(input.length === 0 ? true : false); diff --git "a/solutions/gwonwoo/0123/[\353\254\270\354\240\23409]10\354\247\204\354\210\230\353\245\2742\354\247\204\354\210\230\353\241\234\353\263\200\355\231\230\355\225\230\352\270\260.js" "b/solutions/gwonwoo/0123/[\353\254\270\354\240\23409]10\354\247\204\354\210\230\353\245\2742\354\247\204\354\210\230\353\241\234\353\263\200\355\231\230\355\225\230\352\270\260.js" index 8c32a89..0860e05 100644 --- "a/solutions/gwonwoo/0123/[\353\254\270\354\240\23409]10\354\247\204\354\210\230\353\245\2742\354\247\204\354\210\230\353\241\234\353\263\200\355\231\230\355\225\230\352\270\260.js" +++ "b/solutions/gwonwoo/0123/[\353\254\270\354\240\23409]10\354\247\204\354\210\230\353\245\2742\354\247\204\354\210\230\353\241\234\353\263\200\355\231\230\355\225\230\352\270\260.js" @@ -1,15 +1,27 @@ -const fs = require('fs'); -let num = Number(fs.readFileSync(0).toString()); +// const fs = require('fs'); +// let num = Number(fs.readFileSync(0).toString()); -let result = []; -function solution() { +// let result = []; +// function solution() { +// while (num > 0) { +// let last = num % 2; +// num = Math.floor(num / 2); +// result.push(last); +// } +// // 뒤집어서 올바른 이진수 순서로 변경 +// result.reverse(); +// console.log(result.join('')); +// } +// solution(); + +function solution(s) { + if (s === 0) return 0; + + const arr = []; while (num > 0) { let last = num % 2; num = Math.floor(num / 2); - result.push(last); + arr.push(last); } - // 뒤집어서 올바른 이진수 순서로 변경 - result.reverse(); - console.log(result.join('')); + return arr.reverse().join(''); } -solution(); diff --git "a/solutions/gwonwoo/0123/[\353\254\270\354\240\23410]\352\264\204\355\230\270\355\232\214\354\240\204\355\225\230\352\270\260.js" "b/solutions/gwonwoo/0123/[\353\254\270\354\240\23410]\352\264\204\355\230\270\355\232\214\354\240\204\355\225\230\352\270\260.js" index 31fc3e9..0da694c 100644 --- "a/solutions/gwonwoo/0123/[\353\254\270\354\240\23410]\352\264\204\355\230\270\355\232\214\354\240\204\355\225\230\352\270\260.js" +++ "b/solutions/gwonwoo/0123/[\353\254\270\354\240\23410]\352\264\204\355\230\270\355\232\214\354\240\204\355\225\230\352\270\260.js" @@ -1,32 +1,69 @@ -function isValid(s) { - let check = []; - for (let i = 0; i < s.length; i++) { - check.push(s[i]); +// function isValid(s) { +// let check = []; +// for (let i = 0; i < s.length; i++) { +// check.push(s[i]); - // 현재 스택 길이 - let num = check.length; +// // 현재 스택 길이 +// let num = check.length; - if (check[num - 2] === '[' && check[num - 1] === ']') - check.splice(num - 2, 2); - if (check[num - 2] === '{' && check[num - 1] === '}') - check.splice(num - 2, 2); - if (check[num - 2] === '(' && check[num - 1] === ')') - check.splice(num - 2, 2); - } - if (check.length == 0) { - return true; +// if (check[num - 2] === '[' && check[num - 1] === ']') +// check.splice(num - 2, 2); +// if (check[num - 2] === '{' && check[num - 1] === '}') +// check.splice(num - 2, 2); +// if (check[num - 2] === '(' && check[num - 1] === ')') +// check.splice(num - 2, 2); +// } +// if (check.length == 0) { +// return true; +// } +// } + +// function solution(s) { +// let count = 0; +// // 문자열을 회전시키면서 검사 +// for (let i = 0; i < s.length; i++) { +// // 현재 문자열이 올바른 괄호면 카운트 증가 +// if (isValid(s)) { +// count++; +// } +// // 문자열을 왼쪽으로 한 칸 회전 +// s = s.slice(1) + s[0]; +// } +// return count; +// } + +function isValid(str) { + const stack = []; + // 올바른 괄호 문자열을 객체형태로 저장 + const object = { + '(': ')', + '{': '}', + '[': ']', + }; + for (let i = 0; i < str.length; i++) { + const chr = str[i]; + // 현재 문자가 여는 괄호라면 stack에 push + if (object[chr]) { + stack.push(chr); + } else { + // stack 배열 길이가 0인경우, 배열 마지막에 저장된 값의 value값이 현재 chr과 같지 않은 경우 무조건 false + if (stack.length === 0 || object[stack.pop()] !== chr) { + return false; + } + } } + return stack.length === 0 ? true : false; } function solution(s) { let count = 0; - // 문자열을 회전시키면서 검사 + // s 길이만큼 for문 반복 for (let i = 0; i < s.length; i++) { - // 현재 문자열이 올바른 괄호면 카운트 증가 + // 문자열이 "올바른 괄호 문자열"인지 확인 if (isValid(s)) { count++; } - // 문자열을 왼쪽으로 한 칸 회전 + // s문자열 맨 앞 문자를 s문자열의 맨 뒤로 이동 s = s.slice(1) + s[0]; } return count; diff --git "a/solutions/gwonwoo/0123/[\353\254\270\354\240\23411]\354\247\235\354\247\200\354\226\264\354\240\234\352\261\260\355\225\230\352\270\260.js" "b/solutions/gwonwoo/0123/[\353\254\270\354\240\23411]\354\247\235\354\247\200\354\226\264\354\240\234\352\261\260\355\225\230\352\270\260.js" index 20d0505..3f340de 100644 --- "a/solutions/gwonwoo/0123/[\353\254\270\354\240\23411]\354\247\235\354\247\200\354\226\264\354\240\234\352\261\260\355\225\230\352\270\260.js" +++ "b/solutions/gwonwoo/0123/[\353\254\270\354\240\23411]\354\247\235\354\247\200\354\226\264\354\240\234\352\261\260\355\225\230\352\270\260.js" @@ -1,23 +1,35 @@ -function solution(s) { - let answer = 0; +// function solution(s) { +// let answer = 0; - // 짝을 비교하기 위한 스택 배열 - const stack = []; - // 문자열을 배열로 변환 (문자 하나씩 순회하기 위해) - const arr = [...s]; +// // 짝을 비교하기 위한 스택 배열 +// const stack = []; +// // 문자열을 배열로 변환 (문자 하나씩 순회하기 위해) +// const arr = [...s]; + +// for (let chr of arr) { +// // 스택이 비어있지 않고, 스택의 마지막 값이 현재 문자와 같다면 +// if (stack.length && stack[stack.length - 1] === chr) { +// // 짝이므로 제거 +// stack.pop(); +// } else { +// // 짝이 아니면 스택에 추가 +// stack.push(chr); +// } +// } + +// stack.length === 0 ? (answer = 1) : (answer = 0); + +// return answer; +// } - for (let chr of arr) { - // 스택이 비어있지 않고, 스택의 마지막 값이 현재 문자와 같다면 +function solution(s) { + const stack = []; + for (let chr of s) { if (stack.length && stack[stack.length - 1] === chr) { - // 짝이므로 제거 stack.pop(); } else { - // 짝이 아니면 스택에 추가 stack.push(chr); } } - - stack.length === 0 ? (answer = 1) : (answer = 0); - - return answer; + return stack.length === 0 ? 1 : 0; } diff --git a/solutions/gwonwoo/0123/refactoring b/solutions/gwonwoo/0123/refactoring new file mode 100644 index 0000000..e69de29 diff --git "a/solutions/gwonwoo/0127/[\353\254\270\354\240\23415]\354\232\224\354\204\270\355\221\270\354\212\244\353\254\270\354\240\234.js" "b/solutions/gwonwoo/0127/[\353\254\270\354\240\23415]\354\232\224\354\204\270\355\221\270\354\212\244\353\254\270\354\240\234.js" index d9b1ec7..a44da39 100644 --- "a/solutions/gwonwoo/0127/[\353\254\270\354\240\23415]\354\232\224\354\204\270\355\221\270\354\212\244\353\254\270\354\240\234.js" +++ "b/solutions/gwonwoo/0127/[\353\254\270\354\240\23415]\354\232\224\354\204\270\355\221\270\354\212\244\353\254\270\354\240\234.js" @@ -29,3 +29,5 @@ while (que.length) { } console.log(`<${result.join(', ')}>`); + +const queue = Array.from(queue.fill(1)); diff --git "a/solutions/gwonwoo/0129/[\353\254\270\354\240\23425]\353\262\240\354\212\244\355\212\270\354\225\250\353\262\224.js" "b/solutions/gwonwoo/0129/[\353\254\270\354\240\23425]\353\262\240\354\212\244\355\212\270\354\225\250\353\262\224.js" index fcd6e11..6e30648 100644 --- "a/solutions/gwonwoo/0129/[\353\254\270\354\240\23425]\353\262\240\354\212\244\355\212\270\354\225\250\353\262\224.js" +++ "b/solutions/gwonwoo/0129/[\353\254\270\354\240\23425]\353\262\240\354\212\244\355\212\270\354\225\250\353\262\224.js" @@ -2,11 +2,7 @@ function solution(types, plays) { const answer = []; // gpt 도움 받음 - const music = types.reduce((acc, cur, index) => { - // classic, pop이든 새로운 장르가 생긴다면, 배열 생성 (장르별 묶기 때문) - if (!acc[cur]) acc[cur] = []; - acc[cur].push({ id: index, play: plays[index] }); - }, {}); + const music = types.reduce((acc, cur, index) => {}); // 각 장르별 재생횟수 합계 const totalSum = {}; diff --git "a/solutions/gwonwoo/0130/[\353\254\270\354\240\23428]\355\212\270\353\246\254\354\210\234\355\232\214.js" "b/solutions/gwonwoo/0130/[\353\254\270\354\240\23428]\355\212\270\353\246\254\354\210\234\355\232\214.js" new file mode 100644 index 0000000..e69de29 diff --git "a/solutions/gwonwoo/0130/[\353\254\270\354\240\23429]\354\235\264\354\247\204\355\203\220\354\203\211\355\212\270\353\246\254\352\265\254\355\230\204.js" "b/solutions/gwonwoo/0130/[\353\254\270\354\240\23429]\354\235\264\354\247\204\355\203\220\354\203\211\355\212\270\353\246\254\352\265\254\355\230\204.js" new file mode 100644 index 0000000..e69de29 diff --git "a/solutions/gwonwoo/0130/[\353\254\270\354\240\23430]\354\230\210\354\203\201\353\214\200\354\247\204\355\221\234.js" "b/solutions/gwonwoo/0130/[\353\254\270\354\240\23430]\354\230\210\354\203\201\353\214\200\354\247\204\355\221\234.js" new file mode 100644 index 0000000..e69de29 diff --git "a/solutions/gwonwoo/0130/[\353\254\270\354\240\23431]\353\213\244\353\213\250\352\263\204\354\271\253\354\206\224\355\214\220\353\247\244.js" "b/solutions/gwonwoo/0130/[\353\254\270\354\240\23431]\353\213\244\353\213\250\352\263\204\354\271\253\354\206\224\355\214\220\353\247\244.js" new file mode 100644 index 0000000..e69de29 diff --git "a/solutions/gwonwoo/0130/[\353\254\270\354\240\23432]\352\270\270\354\260\276\352\270\260\352\262\214\354\236\204.js" "b/solutions/gwonwoo/0130/[\353\254\270\354\240\23432]\352\270\270\354\260\276\352\270\260\352\262\214\354\236\204.js" new file mode 100644 index 0000000..e69de29 From bf6c91e4cbb83f2f78b86e1703962b99074db181 Mon Sep 17 00:00:00 2001 From: GwonWooL <229861@naver.com> Date: Wed, 4 Feb 2026 15:43:21 +0900 Subject: [PATCH 7/7] =?UTF-8?q?solve:=20=ED=8A=B8=EB=A6=AC=20>=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=9C=2028=20~=2030?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...70\353\246\254\354\210\234\355\232\214.js" | 44 +++++++++++++++ ...70\353\246\254\352\265\254\355\230\204.js" | 56 +++++++++++++++++++ ...01\353\214\200\354\247\204\355\221\234.js" | 9 +++ 3 files changed, 109 insertions(+) diff --git "a/solutions/gwonwoo/0130/[\353\254\270\354\240\23428]\355\212\270\353\246\254\354\210\234\355\232\214.js" "b/solutions/gwonwoo/0130/[\353\254\270\354\240\23428]\355\212\270\353\246\254\354\210\234\355\232\214.js" index e69de29..d5f1195 100644 --- "a/solutions/gwonwoo/0130/[\353\254\270\354\240\23428]\355\212\270\353\246\254\354\210\234\355\232\214.js" +++ "b/solutions/gwonwoo/0130/[\353\254\270\354\240\23428]\355\212\270\353\246\254\354\210\234\355\232\214.js" @@ -0,0 +1,44 @@ +const fs = require('fs'); +const input = fs.readFileSync(0).toString().trim().split('\n'); +const n = Number(input[0]); + +const tree = {}; + +for (let i = 1; i <= n; i++) { + const [head, left, right] = input[i].split(' '); + tree[head] = [left, right]; +} + +let result = ''; +function preOrder(node) { + if (node === '.') return; + const [left, right] = tree[node]; + result += node; + preOrder(left); + preOrder(right); +} + +function inOrder(node) { + if (node === '.') return; + const [left, right] = tree[node]; + inOrder(left); + result += node; + inOrder(right); +} + +function postOrder(node) { + if (node === '.') return; + const [left, right] = tree[node]; + postOrder(left); + postOrder(right); + result += node; +} + +preOrder('A'); +console.log(result); +result = ''; +inOrder('A'); +console.log(result); +result = ''; +postOrder('A'); +console.log(result); diff --git "a/solutions/gwonwoo/0130/[\353\254\270\354\240\23429]\354\235\264\354\247\204\355\203\220\354\203\211\355\212\270\353\246\254\352\265\254\355\230\204.js" "b/solutions/gwonwoo/0130/[\353\254\270\354\240\23429]\354\235\264\354\247\204\355\203\220\354\203\211\355\212\270\353\246\254\352\265\254\355\230\204.js" index e69de29..fcef57e 100644 --- "a/solutions/gwonwoo/0130/[\353\254\270\354\240\23429]\354\235\264\354\247\204\355\203\220\354\203\211\355\212\270\353\246\254\352\265\254\355\230\204.js" +++ "b/solutions/gwonwoo/0130/[\353\254\270\354\240\23429]\354\235\264\354\247\204\355\203\220\354\203\211\355\212\270\353\246\254\352\265\254\355\230\204.js" @@ -0,0 +1,56 @@ +class Node { + constructor(value) { + this.value = value; + this.left = null; + this.right = null; + } +} + +class BinarySearchTree { + constructor() { + this.root = null; + } + + insert(value) { + const newNode = new Node(value); + + if (!this.root) { + this.root = newNode; + return; + } + + let current = this.root; + + while (true) { + if (value < current.value) { + if (!current.left) { + current.left = newNode; + return; + } + current = current.left; + } else { + if (!current.right) { + current.right = newNode; + return; + } + current = current.right; + } + } + } + + search(value) { + let current = this.root; + while (current) { + if (value === current.value) return true; + current = value < current.value ? current.left : current.right; + } + return false; + } + + inorder(node = this.root) { + if (!node) return; + this.inorder(node.left); + console.log(node.value); + this.inorder(node.right); + } +} diff --git "a/solutions/gwonwoo/0130/[\353\254\270\354\240\23430]\354\230\210\354\203\201\353\214\200\354\247\204\355\221\234.js" "b/solutions/gwonwoo/0130/[\353\254\270\354\240\23430]\354\230\210\354\203\201\353\214\200\354\247\204\355\221\234.js" index e69de29..cf81be5 100644 --- "a/solutions/gwonwoo/0130/[\353\254\270\354\240\23430]\354\230\210\354\203\201\353\214\200\354\247\204\355\221\234.js" +++ "b/solutions/gwonwoo/0130/[\353\254\270\354\240\23430]\354\230\210\354\203\201\353\214\200\354\247\204\355\221\234.js" @@ -0,0 +1,9 @@ +function solution(n, a, b) { + let count = 0; + while (a !== b) { + a = Math.ceil(a / 2); + b = Math.ceil(b / 2); + count++; + } + return count; +}