Find Median From a Data Stream With Two Heaps
The two-heap balance: max-heap low half, min-heap high half. Python solution and complexity analysis for the heap and top-k interview pattern.
The Augmented Dev ยท Archive
Dynamics 365, Power Platform, AI, system design, and web development โ filter by theme or search across every post.
Newsletter
One email per post. No spam, no tracking pixels, unsubscribe anytime.
11 of 325 articles tagged heap-top-k
The two-heap balance: max-heap low half, min-heap high half. Python solution and complexity analysis for the heap and top-k interview pattern.
Bounded max-heap on squared distance โ monotone transforms are free. Python solution and complexity analysis for the heap and top-k interview pattern.
Explore an implicit sorted matrix โ seed one row, expand neighbors lazily. Python solution and complexity analysis for the heap and top-k interview pattern.
The bounded min-heap of size k โ and when quickselect beats it. Python solution and complexity analysis for the heap and top-k interview pattern.
Design a class where the size-k min-heap is the entire state. Python solution and complexity analysis for the heap and top-k interview pattern.
Repeatedly smash the two heaviest โ negation makes heapq a max-heap. Python solution and complexity analysis for the heap and top-k interview pattern.
K-way merge in O(n log k) โ with the tuple tie-break heapq requires. Python solution and complexity analysis for the heap and top-k interview pattern.
No two equal neighbors โ alternate the two most frequent letters. Python solution and complexity analysis for the heap and top-k interview pattern.
Rebuild a string most-frequent-first โ full ordering, so no bounded trick. Python solution and complexity analysis for the heap and top-k interview pattern.
CPU cooldown scheduling โ the frame formula and when idle time vanishes. Python solution and complexity analysis for the heap and top-k interview pattern.
Counter plus bounded heap โ and the bucket-sort answer that beats it. Python solution and complexity analysis for the heap and top-k interview pattern.