minIndex and maxIndex to 0 to keep track of the indices of the minimum and maximum values seen so far within the valid index range.indexDifference.minIndex and maxIndex if the value at i - indexDifference is less than or greater than the values at the current minIndex and maxIndex, respectively.minIndex or maxIndex is greater than or equal to valueDifference.[minIndex, i] or [maxIndex, i].[-1, -1].