Why use a min-heap for k-th largest? It seems backwards. The trick: keep exactly elements in a min-heap.
The heap root is the smallest of these elements, which is the k-th largest overall. For each new element: - If smaller than heap root, ignore it (not in top ) - If larger, remove the root and insert the new element After processing all elements, the root is the k-th largest.