Given an integer array and a window size k, return the median of every contiguous window. This requires keeping the window balanced while elements enter and leave, which is why two heaps plus lazy deletion are commonly used.
nums = array of numbers, k = window size
median of every window in order
Example 1:
Input:
nums = [1,3,-1,-3,5,3,6,7] k = 3
Output:
[1.0,-1.0,-1.0,3.0,5.0,6.0]
Explanation:
This is the standard sliding window median example.
Example 2:
Input:
nums = [1,2] k = 1
Output:
[1.0,2.0]
Explanation:
A window of size 1 always has median equal to the element itself.