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 f54580f commit f0db96aCopy full SHA for f0db96a
top-k-frequent-elements/HodaeSsi.py
@@ -0,0 +1,10 @@
1
+from typing import List
2
+
3
+class Solution:
4
+ def topKFrequent(self, nums: List[int], k: int) -> List[int]:
5
+ dict = {}
6
+ for num in nums:
7
+ dict[num] = dict.get(num, 0) + 1
8
9
+ return sorted(dict.keys(), key=lambda x: dict[x], reverse=True)[:k]
10
0 commit comments