We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent f0999b4 commit 291f956Copy full SHA for 291f956
1 file changed
lkhyun/202512/16 PGM Lv2 귤 고르기.md
@@ -0,0 +1,23 @@
1
+```java
2
+import java.util.*;
3
+class Solution {
4
+ static Map<Integer,Integer> count = new HashMap<>();
5
+ public int solution(int k, int[] tangerine) {
6
+ int answer = 0;
7
+ for(int t : tangerine){
8
+ count.put(t,count.getOrDefault(t,0) + 1);
9
+ }
10
+ List<Integer> countList = new ArrayList<>(count.values());
11
+ countList.sort(Comparator.reverseOrder());
12
+ int sum = 0;
13
+ for(int cur : countList){
14
+ sum+=cur;
15
+ answer++;
16
+ if(sum >= k){
17
+ return answer;
18
19
20
21
22
+}
23
+```
0 commit comments