From c99104609324210a25c21250a0492f1fb6675ae5 Mon Sep 17 00:00:00 2001 From: LiiNi-coder <97495437+LiiNi-coder@users.noreply.github.com> Date: Tue, 9 Dec 2025 22:31:51 +0900 Subject: [PATCH] =?UTF-8?q?[20251209]=20PGM=20/=20LV2=20/=20=ED=95=A0?= =?UTF-8?q?=EC=9D=B8=20=ED=96=89=EC=82=AC=20/=20=EC=9D=B4=EC=9D=B8?= =?UTF-8?q?=ED=9D=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.md" | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 "LiiNi-coder/202512/09 PGM \355\225\240\354\235\270 \355\226\211\354\202\254.md" diff --git "a/LiiNi-coder/202512/09 PGM \355\225\240\354\235\270 \355\226\211\354\202\254.md" "b/LiiNi-coder/202512/09 PGM \355\225\240\354\235\270 \355\226\211\354\202\254.md" new file mode 100644 index 00000000..2649a647 --- /dev/null +++ "b/LiiNi-coder/202512/09 PGM \355\225\240\354\235\270 \355\226\211\354\202\254.md" @@ -0,0 +1,48 @@ +```java +import java.util.*; + +class Solution { + private static HashMap wordsIndex; + + public int solution(String[] wants, int[] number, String[] discounts) { + int answer = 0; + wordsIndex = new HashMap(); + int i = 0; + for(String want : wants){ + wordsIndex.put(want, i++); + } + int[] counts = new int[wants.length]; + + ArrayDeque q = new ArrayDeque(); + String polled; + for(String discount : discounts){ + if(wordsIndex.containsKey(discount)){ + counts[wordsIndex.get(discount)]++; + } + q.offer(discount); + if(q.size() > 10){ + polled = q.poll(); + if(wordsIndex.containsKey(polled)){ + counts[wordsIndex.get(polled)]--; + } + } + + if(q.size() == 10){ + boolean ok = true; + for(int k=0; k