auto commit
This commit is contained in:
parent
c6cfc0a1cb
commit
351fb2e67c
|
@ -403,6 +403,9 @@ public List<Integer> topKFrequent(int[] nums, int k) {
|
|||
}
|
||||
List<Integer> topK = new ArrayList<>();
|
||||
for (int i = buckets.length - 1; i >= 0 && topK.size() < k; i--) {
|
||||
if (buckets[i] == null) {
|
||||
continue;
|
||||
}
|
||||
if (buckets[i].size() <= (k - topK.size())) {
|
||||
topK.addAll(buckets[i]);
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue
Block a user