I have a array A
and want a array B
of same size of A where B[i]
represent length of continous subarray start with A[i]
in which all elements are less than or equal to A[i]
Example
A={1,3,4,2,4,5,1,6}
Output
B={1,1,3,1,1,2,1,1}
Explanation :
For A[2]=4
there is a subarray with element{4,2,4}
, for A[5]=5
there is a subarray {5,1}
for A[7]=6
there is subarray {6}