Unsure with the Solution

There can be further cases like if you are taking the first case and the fourth case then the answer is max(max(A[i]+i)-min(A[i]+i)) but there will be a conditon like A[i]>A[j] & i > j AND A[i]<A[j] & i < j respectivily. How will you handle this conditon?

Click here to start solving coding interview questions