Concept Flow - Top K Frequent Elements Using Heap
Count frequencies
Build min-heap of size k
For each element frequency
If heap size < k
Push freq
Add to heap
Heap contains top k frequencies
Extract elements from heap
Return top k frequent elements
Count element frequencies, keep a min-heap of size k with top frequencies, then extract results.
