Maintain a min-heap of size k containing the k largest elements seen so far.
k elements.k.The heap always stores exactly the k largest elements; the smallest among them is the k-th largest.
Maintain a min-heap of size k containing the k largest elements seen so far.
k elements.k.The heap always stores exactly the k largest elements; the smallest among them is the k-th largest.