Given an array of integers nums representing a data stream, process the numbers one by one and find the median of all elements seen so far after each insertion.
The median is the middle value in an ordered list. If the list size is even, the median is the average of the two middle values.
Return an array of medians — one after each number is added to the stream.
Input: nums = [1, 2, 3]
Output: [1, 1.5, 2]
Explanation:
Input: nums = [5, 2, 8]
Output: [5, 3.5, 5]
Explanation:
Input: nums = [6, 10, 2, 6, 5]
Output: [6, 8, 6, 6, 6]
Explanation:
1 <= nums.length <= 10^5-10^5 <= nums[i] <= 10^5