Find Median from Data Stream
HardLeetCodeHeap / Priority Queue
Approach hintTry it first, then revealHide
Keep the smaller half of the numbers in a max-heap and the larger half in a min-heap, rebalancing after each insertion so their sizes differ by at most one; the median comes from the tops.