min
array to store the minimum value found so far at each index.nums[k]
values.nums
array from right to left.nums[j]
, check if it is greater than min[j]
.min[j]
.nums[j]
, return true
as we have found a 132 pattern.nums[j]
onto the stack.true
, return false
as no 132 pattern exists.