dsa2 min read
Find Median from Data Stream
Maintain a dynamic median using two heaps: a max-heap for the lower half and a min-heap for the upper half.
Read →
webcoderspeed.com
6 articles
Maintain a dynamic median using two heaps: a max-heap for the lower half and a min-heap for the upper half.
Compute medians of all sliding windows using two heaps with lazy deletion for element removal.
Maximize capital after k IPO investments by greedily picking the highest profit project among affordable ones.
Assign tasks to available servers using two heaps: one for free servers and one for busy servers sorted by free time.
Extended practice: compute median for each window in a stream using two-heap with lazy deletion pattern.
Minimize total hiring cost by always choosing the cheapest candidate from the first or last p candidates using two min-heaps.