This is dead-drop simple, but uses built-in sugar.

```
class Solution(object):
def topKFrequent(self, nums, k):
"""
:type nums: List[int]
:type k: int
:rtype: List[int]
"""
hash_table = {}
for num in nums:
if not num in hash_table:
hash_table[num] = 0
hash_table[num] += 1
frequencies = sorted(list(hash_table.items()), key=lambda x: x[1], reverse=True)
return [x[0] for x in frequencies[:k]]
```