Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions lkhyun/202512/16 PGM Lv2 귤 고르기.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
```java
import java.util.*;
class Solution {
static Map<Integer,Integer> count = new HashMap<>();
public int solution(int k, int[] tangerine) {
int answer = 0;
for(int t : tangerine){
count.put(t,count.getOrDefault(t,0) + 1);
}
List<Integer> countList = new ArrayList<>(count.values());
countList.sort(Comparator.reverseOrder());
int sum = 0;
for(int cur : countList){
sum+=cur;
answer++;
if(sum >= k){
return answer;
}
}
return answer;
}
}
```