Say I have an array A = [ 1 3 4 6 7 8] and another array of the same size S = [1 1 0 1 0 1].
I need to check if A(i)+S(i) is greater than or equal to A(i-1)+S(i-1), for the entire length of the array. In other words I'm checking if A + S is monotonically increasing.
However, if S(i-1) is zero, then I want to compare A(i)+S(i) to A(i-2)+S(i-2) instead.
Simply speaking, I need to check if all the elements in A+S are monotonically increasing, ignoring the ones with S=0.