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:true
Explanation:

[1,4,2] is 132 pattern.

Input:nums = [1,2,3,4]
Output:false
Explanation:

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:true
Explanation:

For nums = [-1,3,2,0], the answer is true because the 132 pattern condition is satisfied.

Constraints

  • 1 ≤ nums.length ≤ 2 × 10⁵

Ready to solve this problem?

Practice solo or challenge other developers in a real-time coding battle!