From 8caa3cd3db7bae207a38e3708530ffc7598bea64 Mon Sep 17 00:00:00 2001 From: yoouyeon Date: Sun, 7 Dec 2025 20:33:25 +0900 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=92=A1=20=ED=94=84=EB=A1=9C=EA=B7=B8?= =?UTF-8?q?=EB=9E=98=EB=A8=B8=EC=8A=A4=20131127=20-=20=ED=95=A0=EC=9D=B8?= =?UTF-8?q?=20=ED=96=89=EC=82=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...0\354\235\270_\355\226\211\354\202\254.js" | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git "a/Programmers/Level2/131127_\355\225\240\354\235\270_\355\226\211\354\202\254.js" "b/Programmers/Level2/131127_\355\225\240\354\235\270_\355\226\211\354\202\254.js" index 12954ab..dbda21b 100644 --- "a/Programmers/Level2/131127_\355\225\240\354\235\270_\355\226\211\354\202\254.js" +++ "b/Programmers/Level2/131127_\355\225\240\354\235\270_\355\226\211\354\202\254.js" @@ -5,6 +5,53 @@ 링크 : https://school.programmers.co.kr/learn/courses/30/lessons/131127 */ +// ANCHOR - 2025.12.07 풀이 +function solution(want, number, discount) { + // 원하는 제품 정보 Map 초기화 + const wantMap = new Map(); + for (let idx = 0; idx < want.length; idx++) { + wantMap.set(want[idx], number[idx]); + } + + // 슬라이딩 윈도우에 필요한 변수들 정의 + let answer = 0; + + // 첫번째 윈도우 처리 + for (let day = 0; day <= 9; day++) { + const product = discount[day]; + if (wantMap.has(product)) { + wantMap.set(product, wantMap.get(product) - 1); + } + } + + if ([...wantMap.values()].every((num) => num <= 0)) { + answer += 1; + } + + // 슬라이딩 윈도우 + for (let idx = 0; idx < discount.length - 10; idx++) { + // 앞의 것 빼기 + const first = discount[idx]; + if (wantMap.has(first)) { + wantMap.set(first, wantMap.get(first) + 1); + } + + // 뒤의 것 추가하기 + const last = discount[idx + 10]; + if (wantMap.has(last)) { + wantMap.set(last, wantMap.get(last) - 1); + } + + // 가입 가능 여부 확인 + if ([...wantMap.values()].every((num) => num <= 0)) { + answer++; + } + } + + return answer; +} + +// ANCHOR - 2025.10.06 풀이 function isAnswer(wantMap) { // wantMap의 모든 제품 수량이 0보다 작은지 (답이 되는지) 확인하기 return [...wantMap.values()].every((value) => value <= 0); From d8a27a7e22cafd6a9c8ee5be4b29a861cc0e2c69 Mon Sep 17 00:00:00 2001 From: yoouyeon Date: Sun, 7 Dec 2025 21:07:21 +0900 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=92=A1=20=ED=94=84=EB=A1=9C=EA=B7=B8?= =?UTF-8?q?=EB=9E=98=EB=A8=B8=EC=8A=A4=2042888=20-=20=EC=98=A4=ED=94=88?= =?UTF-8?q?=EC=B1=84=ED=8C=85=EB=B0=A9?= 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" | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git "a/Programmers/Level2/42888_\354\230\244\355\224\210\354\261\204\355\214\205\353\260\251.js" "b/Programmers/Level2/42888_\354\230\244\355\224\210\354\261\204\355\214\205\353\260\251.js" index 1524920..2872960 100644 --- "a/Programmers/Level2/42888_\354\230\244\355\224\210\354\261\204\355\214\205\353\260\251.js" +++ "b/Programmers/Level2/42888_\354\230\244\355\224\210\354\261\204\355\214\205\353\260\251.js" @@ -5,6 +5,27 @@ 링크 : https://school.programmers.co.kr/learn/courses/30/lessons/42888 */ +// ANCHOR - 2025.12.07 풀이 +function solution(record) { + const userMap = new Map(); + for (let idx = 0; idx < record.length; idx++) { + const [type, uid, name] = record[idx].split(" "); + if (type === "Enter" || type === "Change") { + userMap.set(uid, name); + } + } + + const answer = []; + for (let idx = 0; idx < record.length; idx++) { + const [type, uid, _] = record[idx].split(" "); + if (type === "Enter") answer.push(`${userMap.get(uid)}님이 들어왔습니다.`); + else if (type === "Leave") + answer.push(`${userMap.get(uid)}님이 나갔습니다.`); + } + + return answer; +} + // ANCHOR 2025.10.06 풀이 function solution2(record) { const nicknameMap = new Map(); // key: 유저 아이디, value: 현재 닉네임