Skip to content

Commit 72b43d1

Browse files
committed
Feat: top-k-frequent-elements Solution
1 parent 4d07d50 commit 72b43d1

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

top-k-frequent-elements/oddong.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import collections
2+
3+
class Solution:
4+
def topKFrequent(self, nums: List[int], k: int) -> List[int]:
5+
return [num for num, cnt in collections.Counter(nums).most_common(k)]

0 commit comments

Comments
 (0)