Skip to content

Commit ba05d0e

Browse files
committed
Remove unnecessary condition
1 parent 7110331 commit ba05d0e

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

top-k-frequent-elements/yolophg.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ var topKFrequent = function(nums, k) {
1818
const result = [];
1919
// iterate from the highest possible frequency down to the lowest.
2020
for (let i = buckets.length - 1; i >= 0 && result.length < k; i--) {
21-
if (buckets[i].length > 0) {
22-
result.push(...buckets[i]);
23-
}
21+
result.push(...buckets[i]);
2422
}
2523

2624
// ensure the result length is k.

0 commit comments

Comments
 (0)