From 274f8f57c960f76af197c65d9c9d458ede65749a Mon Sep 17 00:00:00 2001 From: JIN921 Date: Fri, 23 Jan 2026 16:39:46 +0900 Subject: [PATCH 1/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 --- problems/0122/problem-list.md | 10 ---- ...24\355\225\230\352\270\260\342\230\205.js" | 1 + ...35\353\247\236\354\266\224\352\270\260.js" | 13 +++++ ...00\355\231\230\355\225\230\352\270\260.js" | 11 ++++ ...14\354\240\204\355\225\230\352\270\260.js" | 50 +++++++++++++++++++ ...34\352\261\260\355\225\230\352\270\260.js" | 15 ++++++ ...74\354\213\235\352\260\200\352\262\251.js" | 35 +++++++++++++ ...21\352\270\260\352\262\214\354\236\204.js" | 0 ...4]\355\221\234\355\216\270\354\247\221.js" | 0 9 files changed, 125 insertions(+), 10 deletions(-) delete mode 100644 problems/0122/problem-list.md create mode 100644 "solutions/yujin/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/yujin/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/yujin/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/yujin/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/yujin/0123/[\353\254\270\354\240\23412]\354\243\274\354\213\235\352\260\200\352\262\251.js" create mode 100644 "solutions/yujin/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" create mode 100644 "solutions/yujin/0123/[\353\254\270\354\240\23414]\355\221\234\355\216\270\354\247\221.js" diff --git a/problems/0122/problem-list.md b/problems/0122/problem-list.md deleted file mode 100644 index 0e621fb..0000000 --- a/problems/0122/problem-list.md +++ /dev/null @@ -1,10 +0,0 @@ -### 22일 목 - 배열 - -[문제 01] 배열 정렬하기★ -[문제 02] 배열 제어하기★★ - -[문제 03] 두 개 뽑아서 더하기★ -[문제 04] 모의고사★ -[문제 05] 행렬의 곱셈★ -[문제 06] 실패율★★ -[문제 07] 방문 길이★★ diff --git "a/solutions/yujin/0122/[\353\254\270\354\240\234 03] \353\221\220 \352\260\234 \353\275\221\354\225\204\354\204\234 \353\215\224\355\225\230\352\270\260\342\230\205.js" "b/solutions/yujin/0122/[\353\254\270\354\240\234 03] \353\221\220 \352\260\234 \353\275\221\354\225\204\354\204\234 \353\215\224\355\225\230\352\270\260\342\230\205.js" index de6b8bc..fb3e02a 100644 --- "a/solutions/yujin/0122/[\353\254\270\354\240\234 03] \353\221\220 \352\260\234 \353\275\221\354\225\204\354\204\234 \353\215\224\355\225\230\352\270\260\342\230\205.js" +++ "b/solutions/yujin/0122/[\353\254\270\354\240\234 03] \353\221\220 \352\260\234 \353\275\221\354\225\204\354\204\234 \353\215\224\355\225\230\352\270\260\342\230\205.js" @@ -6,6 +6,7 @@ function solution(numbers) { } } + // 중복 제거 const sorted_arr = [...new Set(answer)]; return sorted_arr.sort((a, b) => a - b); diff --git "a/solutions/yujin/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/yujin/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..a14d1f1 --- /dev/null +++ "b/solutions/yujin/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,13 @@ +function solution(s) { + let flag = 0; + + for (const ch of s) { + if (ch === '(') { + flag++; + } else flag--; + // flag가 음수가 되면 올바르지 못한 괄호라 바로 false 반환 + if (flag < 0) return false; + } + + return flag === 0 ? true : false; +} diff --git "a/solutions/yujin/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/yujin/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..bfa01db --- /dev/null +++ "b/solutions/yujin/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,11 @@ +function solution(num) { + const answer = []; + while (num > 0) { + answer.push(num % 2); + num = parseInt(num / 2); + } + + return answer.reverse(); +} + +console.log(solution(13)); diff --git "a/solutions/yujin/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/yujin/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..932c07a --- /dev/null +++ "b/solutions/yujin/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,50 @@ +function solution(s) { + let answer = 0; + for (let i = 0; i < s.length; i++) { + const stack = []; + let flag = true; + + // 회전시키기 + let test_arr = s.slice(i) + s.slice(0, i); + + for (const ch of test_arr) { + // 열린 괄호 push + if (ch === '(' || ch === '[' || ch === '{') stack.push(ch); + else { + // 들어간 괄호가 없으면 틀린 것 + if (stack.length === 0) { + flag = false; + break; + } + + // 짝에 맞지 않다면 틀린 것 + if (ch === ')') { + if (stack.pop() === '(') continue; + else { + flag = false; + break; + } + } + if (ch === ']') { + if (stack.pop() === '[') continue; + else { + flag = false; + break; + } + } + if (ch === '}') { + if (stack.pop() === '{') continue; + else { + flag = false; + break; + } + } + } + } + + // flag는 괄호의 짝이 맞는 지 판별 + // stack.length는 괄호의 갯수가 맞는 지 판별 + if (flag && stack.length === 0) answer++; + } + return answer; +} diff --git "a/solutions/yujin/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/yujin/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..7f98c65 --- /dev/null +++ "b/solutions/yujin/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,15 @@ +function solution(s) { + const stack = []; + for (const ch of s) { + // 스택이 빈 경우 문자를 넣고 + if (stack.length === 0) { + stack.push(ch); + } else { + // 아닌 경우 stack 가장 위 문자와 비교 + if (stack[stack.length - 1] === ch) stack.pop(); + else stack.push(ch); + } + } + // 스택이 비었을 경우만 다 비운 것 + return stack.length === 0 ? 1 : 0; +} diff --git "a/solutions/yujin/0123/[\353\254\270\354\240\23412]\354\243\274\354\213\235\352\260\200\352\262\251.js" "b/solutions/yujin/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..33dc5db --- /dev/null +++ "b/solutions/yujin/0123/[\353\254\270\354\240\23412]\354\243\274\354\213\235\352\260\200\352\262\251.js" @@ -0,0 +1,35 @@ +// 정석 풀이 시간 복잡도: O(N) +function solution(prices) { + const n = prices.length; + const answer = Array(n).fill(0); + const stack = []; + + for (let i = 0; i < n; i++) { + while (stack.length && prices[i] < prices[stack[stack.length - 1]]) { + const idx = stack.pop(); + answer[idx] = i - idx; + } + stack.push(i); + } + + while (stack.length) { + const idx = stack.pop(); + answer[idx] = n - 1 - idx; + } + + return answer; +} + +// 다른 풀이 방법 시간 복잡도 : O(N^2) +function solution(prices) { + const n = prices.length; + const answer = Array(n).fill(0); + + for (let i = 0; i < n; i++) { + for (let j = i + 1; j < n; j++) { + answer[i]++; + if (prices[j] < prices[i]) break; + } + } + return answer; +} diff --git "a/solutions/yujin/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/yujin/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..e69de29 diff --git "a/solutions/yujin/0123/[\353\254\270\354\240\23414]\355\221\234\355\216\270\354\247\221.js" "b/solutions/yujin/0123/[\353\254\270\354\240\23414]\355\221\234\355\216\270\354\247\221.js" new file mode 100644 index 0000000..e69de29 From 9e21cc43138be157092923ffc3fc7b175f6ec1c2 Mon Sep 17 00:00:00 2001 From: JIN921 Date: Fri, 23 Jan 2026 19:16:40 +0900 Subject: [PATCH 2/7] =?UTF-8?q?solve:=20=EB=AC=B8=EC=A0=9C=2013?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...21\352\270\260\352\262\214\354\236\204.js" | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git "a/solutions/yujin/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/yujin/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" index e69de29..ebf62c7 100644 --- "a/solutions/yujin/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/yujin/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,20 @@ +function solution(board, moves) { + const stack = []; + let answer = 0; + for (const move of moves) { + const col = move - 1; + for (let i = 0; i < board.length; i++) { + const select = board[i][col]; + + if (select !== 0) { + board[i][col] = 0; + if (stack.length && select === stack.at(-1)) { + answer += 2; + stack.pop(); + } else stack.push(select); + break; + } + } + } + return answer; +} From 674e7d850b641d521854da869b1cc3600a66c451 Mon Sep 17 00:00:00 2001 From: JIN921 Date: Tue, 27 Jan 2026 14:16:03 +0900 Subject: [PATCH 3/7] =?UTF-8?q?solve=20:=20=EB=AC=B8=EC=A0=9C=2015=20~=201?= =?UTF-8?q?7=EB=B2=88=20=EC=A0=95=EB=8B=B5=20=EB=B0=8F=20=ED=81=90=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- solutions/yujin/0127/Queue.js | 38 +++++++++++++++++++ ...60\353\212\245\352\260\234\353\260\234.js" | 21 ++++++++++ ...64\353\223\234\353\255\211\354\271\230.js" | 16 ++++++++ ...0\354\212\244 \353\254\270\354\240\234.js" | 20 ++++++++++ 4 files changed, 95 insertions(+) create mode 100644 solutions/yujin/0127/Queue.js create mode 100644 "solutions/yujin/0127/[\353\254\270\354\240\234 16] \352\270\260\353\212\245\352\260\234\353\260\234.js" create mode 100644 "solutions/yujin/0127/[\353\254\270\354\240\234 17] \354\271\264\353\223\234\353\255\211\354\271\230.js" create mode 100644 "solutions/yujin/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" diff --git a/solutions/yujin/0127/Queue.js b/solutions/yujin/0127/Queue.js new file mode 100644 index 0000000..aabd1ce --- /dev/null +++ b/solutions/yujin/0127/Queue.js @@ -0,0 +1,38 @@ +class Queue { + constructor() { + this.storage = {}; + this.front = 0; + this.rear = 0; + } + + size() { + return this.rear - this.front; + } + + enqueue(element) { + this.storage[this.rear] = element; + this.rear++; + } + + dequeue() { + let item = this.storage[front]; + delete this.storage[this.front]; + this.front++; + + if (this.front === this.rear) { + this.front = 0; + this.rear = 0; + } + + return item; + } +} + +let queue = new Queue(); + +queue.enqueue('hi'); +queue.enqueue('bye'); +queue.enqueue('good'); +queue.enqueue('dog'); + +console.log(queue.storage); diff --git "a/solutions/yujin/0127/[\353\254\270\354\240\234 16] \352\270\260\353\212\245\352\260\234\353\260\234.js" "b/solutions/yujin/0127/[\353\254\270\354\240\234 16] \352\270\260\353\212\245\352\260\234\353\260\234.js" new file mode 100644 index 0000000..72d365d --- /dev/null +++ "b/solutions/yujin/0127/[\353\254\270\354\240\234 16] \352\270\260\353\212\245\352\260\234\353\260\234.js" @@ -0,0 +1,21 @@ +function solution(progresses, speeds) { + const answer = []; + const times = progresses.map((item, idx) => + Math.ceil((100 - item) / speeds[idx]) + ); + let max = times[0]; + let count = 1; + + for (let i = 1; i < times.length; i++) { + if (times[i] <= max) { + count++; + } else { + answer.push(count); + count = 1; + max = times[i]; + } + } + answer.push(count); + + return answer; +} diff --git "a/solutions/yujin/0127/[\353\254\270\354\240\234 17] \354\271\264\353\223\234\353\255\211\354\271\230.js" "b/solutions/yujin/0127/[\353\254\270\354\240\234 17] \354\271\264\353\223\234\353\255\211\354\271\230.js" new file mode 100644 index 0000000..3dcb0ea --- /dev/null +++ "b/solutions/yujin/0127/[\353\254\270\354\240\234 17] \354\271\264\353\223\234\353\255\211\354\271\230.js" @@ -0,0 +1,16 @@ +function solution(cards1, cards2, goal) { + let idx = 0; + let idx1 = 0; + let idx2 = 0; + + while (idx < goal.length) { + if (goal[idx] === cards1[idx1]) { + idx1++; + } else if (goal[idx] === cards2[idx2]) { + idx2++; + } else return 'No'; + + idx++; + } + return 'Yes'; +} diff --git "a/solutions/yujin/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/yujin/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..4472dc8 --- /dev/null +++ "b/solutions/yujin/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,20 @@ +function solution(n, k) { + const queue = Array.from({ length: n }, (_, idx) => idx + 1); + const answer = []; + + let idx = 1; + while (queue.length > 0) { + const item = queue.shift(); + + if (idx % k === 0) { + answer.push(item); + } else { + queue.push(item); + } + idx++; + } + + console.log(`<${answer.join(', ')}>`); +} + +solution(7, 3); From 6b6771c276af2c0f689f746e4f174f6b29c51d3f Mon Sep 17 00:00:00 2001 From: JIN921 Date: Wed, 28 Jan 2026 16:59:26 +0900 Subject: [PATCH 4/7] =?UTF-8?q?solve=20:=20=EB=AC=B8=EC=A0=9C=2018=20~=202?= =?UTF-8?q?2=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 --- ...40\354\235\270\355\226\211\354\202\254.js" | 0 ...22\353\247\214\353\223\244\352\270\260.js" | 28 +++++++++++++++++++ ...30\353\247\214\353\223\244\352\270\260.js" | 13 +++++++++ ...73\355\225\234\354\204\240\354\210\230.js" | 25 +++++++++++++++++ ...35\353\247\220\354\236\207\352\270\260.js" | 23 +++++++++++++++ ...10\355\230\270\353\252\251\353\241\235.js" | 15 ++++++++++ 6 files changed, 104 insertions(+) create mode 100644 "solutions/yujin/0128/[\353\254\270\354\240\234 23]\355\225\240\354\235\270\355\226\211\354\202\254.js" create mode 100644 "solutions/yujin/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/yujin/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/yujin/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/yujin/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/yujin/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" diff --git "a/solutions/yujin/0128/[\353\254\270\354\240\234 23]\355\225\240\354\235\270\355\226\211\354\202\254.js" "b/solutions/yujin/0128/[\353\254\270\354\240\234 23]\355\225\240\354\235\270\355\226\211\354\202\254.js" new file mode 100644 index 0000000..e69de29 diff --git "a/solutions/yujin/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/yujin/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..e37075c --- /dev/null +++ "b/solutions/yujin/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,28 @@ +// 투 포인터 배열 사용 풀이 +function solution(arr, target) { + const sorted_arr = arr.filter((item) => item < target).sort((a, b) => a - b); + + let left = 0; + let right = sorted_arr.length - 1; + while (left < right) { + const sum = sorted_arr[left] + sorted_arr[right]; + if (sum === target) return true; + else if (sum < target) left++; + else right--; + } + + return false; +} + +console.log(solution([1, 2, 3, 4, 8], 6) ? 'True' : 'False'); + +// 해시 풀이 +function solution2(arr, target) { + const set = new Set(arr); + for (const item of arr) { + if (set.has(target - item)) return true; + } + return false; +} + +console.log(solution2([1, 2, 3, 4, 8], 6) ? 'True' : 'False'); diff --git "a/solutions/yujin/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/yujin/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..cf2e5e2 --- /dev/null +++ "b/solutions/yujin/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(stringList, queryList) { + const set = new Set(stringList); + const answer = []; + for (const item of queryList) { + if (set.has(item)) answer.push(true); + else answer.push(false); + } + return answer; +} + +console.log( + solution(['apple', 'banana', 'charry'], ['banana', 'kiwi', 'melon', 'apple']) +); diff --git "a/solutions/yujin/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/yujin/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..9c50620 --- /dev/null +++ "b/solutions/yujin/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,25 @@ +function solution(participant, completion) { + const map = new Map(); + + // 완주자 넣어놓고 + for (const p of completion) { + map.set(p, 0); + } + + // 완주자에 있으면 +1 없으면 0 + for (const c of participant) { + map.set(c, map.get(c) + 1 || 0); + } + + // 중복이거나 완주 못한 경우는 1이 아님 + for (const [key, value] of map) { + if (value !== 1) return key; + } +} + +console.log( + solution( + ['marina', 'josipa', 'nikola', 'vinko', 'filipa'], + ['josipa', 'filipa', 'marina', 'nikola'] + ) +); diff --git "a/solutions/yujin/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/yujin/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..4315e0e --- /dev/null +++ "b/solutions/yujin/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,23 @@ +function solution(n, words) { + var answer = [0, 0]; + + const set = new Set(); + + let prev_word = words[0]; + set.add(prev_word); + + for (let i = 1; i < words.length; i++) { + const current_word = words[i]; + if (set.has(current_word) || prev_word.at(-1) !== current_word[0]) { + // 이거 순서 구하는 로직은 내가 못해서 gpt의 도움을 받앗슨... + const idx = (i % n) + 1; + const number_idx = Math.floor(i / n) + 1; + return [idx, number_idx]; + } else { + set.add(current_word); + prev_word = current_word; + } + } + + return answer; +} diff --git "a/solutions/yujin/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/yujin/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..b97b201 --- /dev/null +++ "b/solutions/yujin/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,15 @@ +function solution(phone_book) { + phone_book.sort((a, b) => (a > b ? 1 : -1)); + let comp_word = phone_book[0]; + for (let i = 1; i < phone_book.length; i++) { + if (phone_book[i].startsWith(comp_word)) { + return true; + } else { + comp_word = phone_book[i]; + } + } + + return false; +} + +console.log(solution(['119', '97674223', '1195524421'])); From 81e05b550d4b6a40a0559b20aaa16d14960fd817 Mon Sep 17 00:00:00 2001 From: JIN921 Date: Wed, 28 Jan 2026 17:59:53 +0900 Subject: [PATCH 5/7] =?UTF-8?q?solve=20:=20=EB=AC=B8=EC=A0=9C=2023?= =?UTF-8?q?=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 --- ...40\354\235\270\355\226\211\354\202\254.js" | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git "a/solutions/yujin/0128/[\353\254\270\354\240\234 23]\355\225\240\354\235\270\355\226\211\354\202\254.js" "b/solutions/yujin/0128/[\353\254\270\354\240\234 23]\355\225\240\354\235\270\355\226\211\354\202\254.js" index e69de29..afcbbe3 100644 --- "a/solutions/yujin/0128/[\353\254\270\354\240\234 23]\355\225\240\354\235\270\355\226\211\354\202\254.js" +++ "b/solutions/yujin/0128/[\353\254\270\354\240\234 23]\355\225\240\354\235\270\355\226\211\354\202\254.js" @@ -0,0 +1,37 @@ +function solution(want, number, discount) { + let answer = 0; + + // 원하는 상품 목록 + const want_map = new Map(); + for (let i = 0; i < want.length; i++) { + want_map.set(want[i], number[i]); + } + + // 할인 품목 10일치 + const comp_map = new Map(); + for (let i = 0; i < 10; i++) { + const item = discount[i]; + comp_map.set(item, (comp_map.get(item) || 0) + 1); + } + + // 원하는 상품과 할인품목 10일치 비교 함수 + function isSame(map2) { + for (const [key, value] of want_map) { + if (map2.get(key) !== value) return false; + } + return true; + } + if (isSame(comp_map)) answer++; + + // 남은 기간도 비교 + for (let i = 10; i < discount.length; i++) { + // 가장 앞에 있는 할인 품목 1개 제거 + comp_map.set(discount[i - 10], (comp_map.get(discount[i - 10]) || 0) - 1); + + // 할인 품목 하나 추가 + comp_map.set(discount[i], (comp_map.get(discount[i]) || 0) + 1); + + if (isSame(comp_map)) answer++; + } + return answer; +} From 9f13a9591f71947f938fcf32fe312b10f8440b29 Mon Sep 17 00:00:00 2001 From: JIN921 Date: Thu, 29 Jan 2026 16:47:46 +0900 Subject: [PATCH 6/7] =?UTF-8?q?=20solve=20:=20=EB=AC=B8=EC=A0=9C=2024=20~?= =?UTF-8?q?=2027=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 --- ...10\354\261\204\355\214\205\353\260\251.js" | 22 ++++++++ ...44\355\212\270\354\225\250\353\262\224.js" | 28 ++++++++++ ...60\352\263\274\353\260\233\352\270\260.js" | 38 +++++++++++++ ...64\353\246\254\353\211\264\354\226\274.js" | 56 +++++++++++++++++++ 4 files changed, 144 insertions(+) create mode 100644 "solutions/yujin/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/yujin/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/yujin/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/yujin/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/yujin/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/yujin/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..62d8bd8 --- /dev/null +++ "b/solutions/yujin/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) { + let answer = []; + const arr = record.map((item) => item.split(' ')); + + const obj = {}; + + for (const [act, id, name] of arr) { + // 떠나는 경우는 이름과 상관이 없으므로 냅두기 + if (act !== 'Leave') { + obj[id] = name; + } + } + for (const [act, id, _] of arr) { + const name = obj[id]; + if (act === 'Enter') { + answer.push(`${name}님이 들어왔습니다.`); + } else if (act === 'Leave') { + answer.push(`${name}님이 나갔습니다.`); + } + } + return answer; +} diff --git "a/solutions/yujin/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/yujin/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..5d40c09 --- /dev/null +++ "b/solutions/yujin/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,28 @@ +function solution(genres, plays) { + let answer = []; + const albums = []; + for (let i = 0; i < genres.length; i++) { + albums.push([genres[i], i, plays[i]]); + } + + const total_plays = new Map(); + for (const [genre, _, play] of albums) { + total_plays.set(genre, (total_plays.get(genre) || 0) + play); + } + const total_arr = [...total_plays].sort((a, b) => b[1] - a[1]); + + albums.sort((a, b) => b[2] - a[2]); + for (const [genre, _] of total_arr) { + const songs = albums.filter((item) => item[0] === genre).slice(0, 2); + songs.forEach(([_, idx, _play]) => answer.push(idx)); + } + + return answer; +} + +console.log( + solution( + ['classic', 'pop', 'classic', 'classic', 'pop'], + [500, 600, 150, 800, 2500] + ) +); diff --git "a/solutions/yujin/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/yujin/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..947997f --- /dev/null +++ "b/solutions/yujin/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,38 @@ +function solution(id_list, report, k) { + let answer = []; + // 누가 누구 신고했는지 리스트 만들기 + const report_map = new Map(); + for (const item of report) { + const [reporter, reported] = item.split(' '); + if (report_map.has(reporter)) { + report_map.get(reporter).add(reported); + } else { + // 같은 사람 신고한 건 안 들어가니까 set으로 중복 제거 + report_map.set(reporter, new Set()); + report_map.get(reporter).add(reported); + } + } + + // 누가 몇번 신고당했는지 리스트 만들기 + const acc_report_map = new Map(); + [...report_map].map(([_, reported_list]) => { + reported_list.forEach((reported) => + acc_report_map.set(reported, (acc_report_map.get(reported) || 0) + 1) + ); + }); + + for (const id of id_list) { + if (report_map.get(id)) { + let result = 0; + report_map.get(id).forEach((item) => { + if (acc_report_map.get(item) >= k) { + result++; + } + }); + answer.push(result); + } else { + answer.push(0); + } + } + return answer; +} diff --git "a/solutions/yujin/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/yujin/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..965838a --- /dev/null +++ "b/solutions/yujin/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,56 @@ +function getCombination(arr, length) { + // 1개만 뽑는 경우 탈출 + if (length === 1) return arr.map((v) => [v]); + const result = []; + + arr.forEach((fixed, idx, arr) => { + // 현재 index 이후 요소만 추출 + const rest = arr.slice(idx + 1); + + // 선택된 요소 이전 요소들은 제외하고 재귀 호출 + const combis = getCombination(rest, length - 1); + + // 선택된 요소와 재귀 호출을 통해 구한 조합 합침 + const combine = combis.map((v) => [fixed, ...v]); + + // 결과 값을 추가 + result.push(...combine); + }); + return result; +} + +function solution(orders, course) { + const answer = []; + + // 각 코스요리 길이에 대해서 + for (const c of course) { + const menu = []; + // 모든 주문에 대해서 + for (const order of orders) { + const orderArr = order.split('').sort(); + + // 메뉴 구성을 모두 구하기 + const comb = getCombination(orderArr, c); + menu.push(...comb); + } + + // 각 메뉴 구성이 몇 번 주문되었는지 카운팅 + const counter = {}; + for (const m of menu) { + const key = m.join(''); + counter[key] = (counter[key] || 0) + 1; + } + const max = Math.max(...Object.values(counter)); + + // 가장 많이 주문된 구성이 1번 이상 주문된 경우 + if (max > 1) { + for (const [key, value] of Object.entries(counter)) { + // 가장 많은 주문을 찾아서 정답 배열에 추가 + if (value === max) answer.push(key); + } + } + } + + // 오름차순 정렬 후 반환 + return answer.sort(); +} From 61d322a6735ce3325e30493d5fe982558b3154a1 Mon Sep 17 00:00:00 2001 From: JIN921 Date: Tue, 3 Feb 2026 16:54:26 +0900 Subject: [PATCH 7/7] =?UTF-8?q?solve=20:=20=EB=AC=B8=EC=A0=9C=2028=20~=203?= =?UTF-8?q?0=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 --- ...70\353\246\254\354\210\234\355\232\214.js" | 29 +++++++++ ...70\353\246\254\352\265\254\355\230\204.js" | 61 +++++++++++++++++++ ...01\353\214\200\354\247\204\355\221\234.js" | 11 ++++ ...0\353\246\254_\354\210\234\355\232\214.js" | 48 +++++++++++++++ 4 files changed, 149 insertions(+) create mode 100644 "solutions/yujin/0130/[\353\254\270\354\240\23428]\355\212\270\353\246\254\354\210\234\355\232\214.js" create mode 100644 "solutions/yujin/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/yujin/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/yujin/0130/\355\212\270\353\246\254_\354\210\234\355\232\214.js" diff --git "a/solutions/yujin/0130/[\353\254\270\354\240\23428]\355\212\270\353\246\254\354\210\234\355\232\214.js" "b/solutions/yujin/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..5430df1 --- /dev/null +++ "b/solutions/yujin/0130/[\353\254\270\354\240\23428]\355\212\270\353\246\254\354\210\234\355\232\214.js" @@ -0,0 +1,29 @@ +const fs = require('fs'); +const input = fs.readFileSync('/dev/stdin').toString().trim().split('\n'); + +const N = Number(input[0]); +const tree = {}; + +for (let i = 1; i <= N; i++) { + const [node, left, right] = input[i]; + tree[node] = { left, right }; +} + +function preorder(node) { + if (node === '.') return ''; + return node + preorder(tree[node].left) + preorder(tree[node].right); +} + +function inorder(node) { + if (node === '.') return ''; + return preorder(tree[node].left) + node + preorder(tree[node].right); +} + +function postorder(node) { + if (node === '.') return ''; + return postorder(tree[node].left) + postorder(tree[node].right) + node; +} + +console.log(preorder('A')); +console.log(inorder('A')); +console.log(postorder('A')); diff --git "a/solutions/yujin/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/yujin/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..dbd0967 --- /dev/null +++ "b/solutions/yujin/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,61 @@ +class Node { + constructor(value) { + this.left = null; + this.right = null; + this.value = value; + } +} + +class BST { + constructor() { + this.root = null; + } + insert(value) { + if (!this.root) { + this.root = new Node(value); + return; + } else { + let cur = this.root; + while (true) { + // 삽입 하려는 값이 현재 자식노드보다 작은 경우 + if (value < cur) { + // 왼쪽으로 이동 + if (cur.left) { + cur = cur.left; + } else { + cur.left = new Node(value); + break; + } + } else { + if (cur.right) { + cur = cur.right; + } else { + cur.right = new Node(value); + break; + } + } + } + } + } + + search(value) { + let cur = this.root; + while (cur) { + if (cur.value === value) return true; + else if (cur.value < value) cur = cur.left; + else cur = cur.right; + } + return false; + } +} + +function solution(lst, searchList) { + const bst = new BST(); + + for (const num of lst) { + bst.insert(num); + } + return searchList.map((v) => bst.search(v)); +} + +console.log(solution([5, 3, 8, 4, 2, 1, 7, 10], [1, 2, 5, 6])); diff --git "a/solutions/yujin/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/yujin/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..b05f9bc --- /dev/null +++ "b/solutions/yujin/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,11 @@ +function solution(n, a, b) { + let answer = 0; + + while (a !== b) { + a = Math.ceil(a / 2); + b = Math.ceil(b / 2); + answer++; + } + + return answer; +} diff --git "a/solutions/yujin/0130/\355\212\270\353\246\254_\354\210\234\355\232\214.js" "b/solutions/yujin/0130/\355\212\270\353\246\254_\354\210\234\355\232\214.js" new file mode 100644 index 0000000..d4b099e --- /dev/null +++ "b/solutions/yujin/0130/\355\212\270\353\246\254_\354\210\234\355\232\214.js" @@ -0,0 +1,48 @@ +function solution(arr) { + // 전위 순회 + function preOrder(nodes, idx) { + const left = idx * 2 + 1; + const right = idx * 2 + 2; + + if (idx < nodes.length) { + let ret = `${nodes[idx]}`; + ret += preOrder(nodes, left); + ret += preOrder(nodes, right); + + return ret; + } + return ''; + } + + // 중위 순회 + function inOrder(nodes, idx) { + const left = idx * 2 + 1; + const right = idx * 2 + 2; + + if (idx < nodes.length) { + let ret = inOrder(nodes, left); + ret += `${nodes[idx]}`; + ret += inOrder(nodes, right); + return ret; + } + return ''; + } + + // 후위 순회 + function postOrder(nodes, idx) { + let left = idx * 2 + 1; + let right = idx * 2 + 2; + + if (idx < nodes.length) { + let ret = postOrder(nodes, left); + ret += postOrder(nodes, right); + ret += `${nodes[idx]}`; + return ret; + } + return ''; + } + + return [preOrder(arr, 0), inOrder(arr, 0), postOrder(arr, 0)]; +} + +console.log(solution([1, 2, 3, 4, 5, 6, 7]));