Given an array A of N integers . Find the maximum of value of i − j such that : 1) j ≤ i 2) A[j] ≤ A[i]
Note : i and j are 0-based indices
Constraints : N≤106,A[i] ≤ 109 for 0 ≤i ≤ N−1
Ex :
- A = [1,2,3,4,5]
j = 0 , i = 4 gives maximum difference of 4 satisfying the given conditions - A = [8,4,8,7,6,6,3]
j = 1 , i = 5 gives maximum difference of 4 satisfying the given conditions