Description
Given an array of n integers nums, a 132 pattern is a subsequence of three integers nums[i], nums[j], nums[k] such that i < j < k and nums[i] < nums[k] < nums[j].
Examples
Input:
nums = [3,1,4,2]Output:
trueExplanation:
[1,4,2] is 132 pattern.
Input:
nums = [1,2,3,4]Output:
falseExplanation:
For nums = [1,2,3,4], the answer is false because the 132 pattern condition is not met.
Input:
nums = [-1,3,2,0]Output:
trueExplanation:
For nums = [-1,3,2,0], the answer is true because the 132 pattern condition is satisfied.
Constraints
- •
1 ≤ nums.length ≤ 2 × 10⁵