132 Pattern
MediumStack
Decode it first. Clues, constraints, pattern and plan before any code.A 132 pattern in a list nums is three positions i < j < k with nums[i] < nums[k] < nums[j]: a small value, then a big one, then one in between (like the digits 1, 3, 2). Return true if nums contains a 132 pattern, otherwise false. The three values do not have to be next to each other.
nums = [1, 2, 3, 4] → false
nums = [3, 1, 4, 2] → true (1, 4, 2)
nums = [-1, 3, 2, 0] → true (-1, 3, 2)Constraints
n == nums.length1 <= n <= 2 * 10^5-10^9 <= nums[i] <= 10^9