120. Running Median of a Stream
HardPriority queues & heaps
Numbers arrive one at a time. After each arrival, record the median of all numbers seen so far. Return the list of medians.
When the count is even, the median is the average of the two middle values (it may end in .5).
Example 1
Input: stream = [5, 15, 1, 3] Output: [5, 10, 5, 4]
Constraints
1 ≤ stream.length ≤ 10⁴-10⁵ ≤ stream[i] ≤ 10⁵