Hi,
Can’t we use minHeap here? My logic is as below:
- insert into the minheap one by one.
- If minHeap size is greater than k, then pop().
- At last what we have inside the heap is top K largest elements.
Isn’t it better than using vector as minHeap? Am I missing anything here?
Thanks,
Souvik