Blind 75 Heap Questions
1 problem · Free practice
Find Median From Data Stream uses two heaps to keep the lower and upper halves of the values separate. The solution depends on two invariants: every value in the lower half is at most every value in the upper half, and their sizes differ by at most one. Maintaining those rules makes the median available at the roots.
Practice heaps
What to focus on
- Use a max-heap for the lower half and a min-heap for the upper half.
- Explain how insertion preserves ordering as well as size balance.
- Test negative numbers, duplicate values, and both odd and even stream lengths.