Median from data stream
Your task
You receive integers one at a time from a stream. After each new integer, report the median of all integers seen so far. Return a list of medians (as floats), one per input element. The median of an even count is the average of the two middle values. nums has at least one element.
Examples
running_medians(nums: list[int]) -> list[float]Example 1
Input
running_medians([1, 2, 3, 4])Output
[1, 1.5, 2, 2.5]