Mental Model
Find the elements that appear most often by counting them, then keep only the top K using a special list that quickly removes the least frequent.
Analogy: Imagine you have a bag of colored balls and want to find the top K colors that appear most. You count each color, then keep only the K colors with the most balls by always removing the color with the fewest balls when you add a new one.
Input array: [1,1,1,2,2,3]
Frequency map: {1:3, 2:2, 3:1}
Min-heap (size K=2):
[2:2]
[1:3]
Top K frequent elements: 1, 2