Concept Flow - Median of Data Stream Using Two Heaps
New number arrives
Compare with maxHeap top?
Add to maxHeap
Balance heaps size?
If size difference > 1
Move root from bigger heap to smaller heap
Calculate median
Return median
New numbers go into one of two heaps (maxHeap for smaller half, minHeap for larger half). We keep heaps balanced, then median is top(s) of heaps.
