Given a non-empty array of integers, return the k most frequent elements.
Input: nums = [1,1,1,2,2,3], k = 2 Output: [1,2]
Input: nums = , k = 1 Output: 
For submission or more details about Top K Frequent Elements problem
- Create a hashmap with all the value and their occurrences
- Sort the frequency and return the k frequencies
- Take items having those frequencies