Given an array as input find the output array that has median of each sub array whose index starts from 0 to i(i = 1,2...array.length-1).
So basically given array A[], output array B[]. B[i] is the median of A[0] ... A[i].
I am thinking about using dynamic programming to store the two numbers before and after the median of each sub array. But it somehow gets complicated. Is there any easier solution?