I have tried the accepted solution on the array 2 -1 3 4 5
Accepted Solution
Upon debugging I found the following
LMax= 2 1 4 8 13
LMin= 2 -1 2 4 5
RMax= 13 11 12 9 5
RMin= 1 -1 3 4 5
So I want to know why a max value decreases when going from left to right or max value decreases moving from right to left and vice versa for min values?
What I could understand from problem is that we have to find two pairs of indexs such that their absolute diff of sum of elements is max. And len(j-i)+ len(l-k) <= n
My Solution
I found these array to be
LMax= 2 2 4 8 13
LMin= 2 -1 -1 -1 -1
RMax= 13 12 12 9 5
RMin= -1 -1 3 4 5
So can anyone explain ?