Mental Model
We want to find the k numbers that appear most often in a list by counting frequencies and using a small structure to keep track of the top counts.
Analogy: Imagine you have a bag of colored balls and want to find the k colors you have the most of. You count how many balls of each color you have, then keep only the top k colors in a small box that always removes the least frequent color when a new more frequent one comes in.
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) ] ← keeps top 2 frequent elements
Heap root points to smallest frequency