dsa2 min read
Kth Largest Element in a Stream
Maintain a min-heap of size K to track the Kth largest element as numbers are added to a stream.
Read →
webcoderspeed.com
3 articles
Maintain a min-heap of size K to track the Kth largest element as numbers are added to a stream.
Find K points closest to the origin using a max-heap of size K or quickselect for O(n) average.
Find the subsequence of length k with the largest sum by selecting top k values while preserving original order.