132 Pattern

Medium · Stack & Monotonic Stack · about 25 minutes

Asked at DoorDash, Amazon, Google, Microsoft.

Look for a "132" pattern in nums: three positions i < j < k where the value at k falls strictly between the other two, i.e. nums[i] < nums[k] < nums[j]. Return true if one exists.

Related guides