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 2831e27 commit 7123351Copy full SHA for 7123351
top-k-frequent-elements/yayyz.py
@@ -0,0 +1,7 @@
1
+from collections import Counter
2
+import heapq
3
+
4
+class Solution:
5
+ def topKFrequent(self, nums: List[int], k: int) -> List[int]:
6
+ count_dict = Counter(nums)
7
+ return heapq.nlargest(k, count_dict.keys(), key=count_dict.get)
0 commit comments