Intuition
- Using two heaps, maxHeap and minHeap, ensure the size of max always not smaller the min, so the median is the max peek(when max is one more than min) or the middle of max peek and min peek(when the sizes of them are equal).
solution
|
|
promote
The code can be simplify.
|
|