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 7110331 commit ba05d0eCopy full SHA for ba05d0e
top-k-frequent-elements/yolophg.js
@@ -18,9 +18,7 @@ var topKFrequent = function(nums, k) {
18
const result = [];
19
// iterate from the highest possible frequency down to the lowest.
20
for (let i = buckets.length - 1; i >= 0 && result.length < k; i--) {
21
- if (buckets[i].length > 0) {
22
- result.push(...buckets[i]);
23
- }
+ result.push(...buckets[i]);
24
}
25
26
// ensure the result length is k.
0 commit comments