From 98713aff5e6114c6c7e8657447d8127a87399b46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EC=8B=A0=EC=A7=80?= <101992179+ksinji@users.noreply.github.com> Date: Tue, 21 Oct 2025 19:24:37 +0900 Subject: [PATCH] =?UTF-8?q?[20251021]=20PGM=20/=20LV2=20/=20=EA=B7=A4=20?= =?UTF-8?q?=EA=B3=A0=EB=A5=B4=EA=B8=B0=20/=20=EA=B0=95=EC=8B=A0=EC=A7=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...4 \352\263\240\353\245\264\352\270\260.md" | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 "ksinji/202510/21 PGM \352\267\244 \352\263\240\353\245\264\352\270\260.md" diff --git "a/ksinji/202510/21 PGM \352\267\244 \352\263\240\353\245\264\352\270\260.md" "b/ksinji/202510/21 PGM \352\267\244 \352\263\240\353\245\264\352\270\260.md" new file mode 100644 index 00000000..acecaf0f --- /dev/null +++ "b/ksinji/202510/21 PGM \352\267\244 \352\263\240\353\245\264\352\270\260.md" @@ -0,0 +1,32 @@ +```java +import java.util.*; + +class Solution { + public int solution(int k, int[] tangerine) { + int answer = 0; + Map count = new HashMap<>(); + + for (int i : tangerine){ + count.put(i, count.getOrDefault(i, 0)+1); + } + + List countList = new ArrayList<>(); + + for (int i : count.values()){ + countList.add(i); + } + + Collections.sort(countList, Collections.reverseOrder()); + + int sum = 0; + for (int i : countList){ + sum += i; + answer++; + if (sum >= k){ + return answer; + } + } + return answer; + } +} +```