Sliding Window Median — Two Heaps with Lazy Deletion
LeetCode 480 (Hard) — a Google and Bloomberg favorite. Compute the median of every k-sized window using two heaps with a lazy deletion hash map.
1582 articles
LeetCode 480 (Hard) — a Google and Bloomberg favorite. Compute the median of every k-sized window using two heaps with a lazy deletion hash map.
LeetCode 23 (Hard) — the most-asked heap problem at FAANG. Merge k sorted linked lists in O(N log k) using a min-heap that always tracks the smallest active head.
LeetCode 378 (Medium) — a Google and Amazon staple. Solve k-th smallest in a row-and-column-sorted matrix with a min-heap k-way merge or binary search on the value range.
LeetCode 373 (Medium) — find the k smallest pair sums from two sorted arrays in O(k log k) by treating the implicit pair-sum matrix as a sorted matrix and running a min-heap k-way merge.
LeetCode 264 (Medium) — generate the n-th ugly number using a min-heap with a dedupe set or a three-pointer DP merge that runs in pure O(n).