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 dd26705 commit 0bab862Copy full SHA for 0bab862
LiiNi-coder/202510/27 PGM 귤 고르기.md
@@ -0,0 +1,24 @@
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> countsAtSize = new TreeMap<>();
8
+ for(int t: tangerine){
9
+ countsAtSize.put(t, countsAtSize.getOrDefault(t, 0) + 1);
10
+ }
11
+ List<Integer> ss = new ArrayList<>(countsAtSize.values());
12
+ Collections.sort(ss, Collections.reverseOrder());
13
14
+ for(int s: ss){
15
+ k -= s;
16
+ answer++;
17
+ if(k<=0){
18
+ break;
19
20
21
+ return answer;
22
23
+}
24
+```
0 commit comments