We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 408c446 commit 98713afCopy full SHA for 98713af
ksinji/202510/21 PGM 귤 고르기.md
@@ -0,0 +1,32 @@
1
+```java
2
+import java.util.*;
3
+
4
+class Solution {
5
+ public int solution(int k, int[] tangerine) {
6
+ int answer = 0;
7
+ Map<Integer, Integer> count = new HashMap<>();
8
9
+ for (int i : tangerine){
10
+ count.put(i, count.getOrDefault(i, 0)+1);
11
+ }
12
13
+ List<Integer> countList = new ArrayList<>();
14
15
+ for (int i : count.values()){
16
+ countList.add(i);
17
18
19
+ Collections.sort(countList, Collections.reverseOrder());
20
21
+ int sum = 0;
22
+ for (int i : countList){
23
+ sum += i;
24
+ answer++;
25
+ if (sum >= k){
26
+ return answer;
27
28
29
30
31
+}
32
+```
0 commit comments