Numbers arrive one at a time. After each number, report the median of all numbers so far: the middle one for an odd count, or the average of the two middle ones for an even count. Return the list of medians (as decimals such as 2.0 and 2.5).
For [5, 15, 1, 3] the answer is [5.0, 10.0, 5.0, 4.0].
Example 1
Input:
running_median([5, 15, 1, 3])
Output:
[5.0, 10.0, 5.0, 4.0]
Example 2
Input:
running_median([2])
Output:
[2.0]
0 <= len(nums) <= 100000-10**9 <= nums[i] <= 10**9No results yet
Run your code to check it against the examples, or submit to run every test.