minDeque
for tracking the minimum values and maxDeque
for tracking the maximum values.left
and right
to 0, which represent the bounds of the current window.right
pointer.
left
pointer to shrink the window from the front, and remove the front elements of the deques if they are equal to nums[left]
.