This commit is contained in:
2026-06-05 22:18:39 +08:00
parent 0aed1528e2
commit 14d05011d5
7 changed files with 169 additions and 7 deletions
@@ -40,9 +40,11 @@ Given an integer array ~nums~ and an integer ~k~, return /the/ ~k~ /most frequen
Write your approach here.
** TODO Python
#+begin_src python
#+begin_src python :lc-problem 347 :lc-lang python3
class Solution:
def topKFrequent(self, nums: List[int], k: int) -> List[int]:
from collections import Counter
return [n for n, _ in Counter(nums).most_common(k)]
#+end_src
** TODO C++