Mental Model
We want to find the K numbers that appear most often in a list by counting frequencies and keeping only the top K using a special list that quickly removes the smallest frequency.
Analogy: Imagine you have a basket of fruits and want to keep only the top K types that appear most often. You count each fruit type, then keep a small basket that always drops the least frequent fruit 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):
[ (1,3), (2,2) ] ← keeps top 2 frequent elements
Output: [1, 2]