Given an integer array `nums` and an integer `k`, return the k most frequent elements.
nums = [1,1,1,2,2,3], k = 2
[1,2]
nums = [1], k = 1
[1]