dsa2 min read
Amazon — Kth Largest Element in a Stream (Min-Heap)
Design a stream that always returns the kth largest element after each add. Uses a min-heap of size k — the top is always the kth largest.
Read →
webcoderspeed.com
2 articles
Design a stream that always returns the kth largest element after each add. Uses a min-heap of size k — the top is always the kth largest.
Maintain a running median from a data stream using two heaps: a max-heap for the lower half and a min-heap for the upper half, rebalancing after each insertion.