Domanda di colloquio di Meta

Given an integer array nums and an integer k, return the k most frequent elements.