Amazon interview question

Leetcode style question: Top K frequent elements