mirror of
				https://gitee.com/coder-xiaomo/leetcode-problemset
				synced 2025-11-04 03:33:12 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			38 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			38 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
<p>Given an array of <code>n</code> integers <code>nums</code>, a <strong>132 pattern</strong> is a subsequence of three integers <code>nums[i]</code>, <code>nums[j]</code> and <code>nums[k]</code> such that <code>i < j < k</code> and <code>nums[i] < nums[k] < nums[j]</code>.</p>
 | 
						|
 | 
						|
<p>Return <em><code>true</code> if there is a <strong>132 pattern</strong> in <code>nums</code>, otherwise, return <code>false</code>.</em></p>
 | 
						|
 | 
						|
<p> </p>
 | 
						|
<p><strong>Example 1:</strong></p>
 | 
						|
 | 
						|
<pre>
 | 
						|
<strong>Input:</strong> nums = [1,2,3,4]
 | 
						|
<strong>Output:</strong> false
 | 
						|
<strong>Explanation:</strong> There is no 132 pattern in the sequence.
 | 
						|
</pre>
 | 
						|
 | 
						|
<p><strong>Example 2:</strong></p>
 | 
						|
 | 
						|
<pre>
 | 
						|
<strong>Input:</strong> nums = [3,1,4,2]
 | 
						|
<strong>Output:</strong> true
 | 
						|
<strong>Explanation:</strong> There is a 132 pattern in the sequence: [1, 4, 2].
 | 
						|
</pre>
 | 
						|
 | 
						|
<p><strong>Example 3:</strong></p>
 | 
						|
 | 
						|
<pre>
 | 
						|
<strong>Input:</strong> nums = [-1,3,2,0]
 | 
						|
<strong>Output:</strong> true
 | 
						|
<strong>Explanation:</strong> There are three 132 patterns in the sequence: [-1, 3, 2], [-1, 3, 0] and [-1, 2, 0].
 | 
						|
</pre>
 | 
						|
 | 
						|
<p> </p>
 | 
						|
<p><strong>Constraints:</strong></p>
 | 
						|
 | 
						|
<ul>
 | 
						|
	<li><code>n == nums.length</code></li>
 | 
						|
	<li><code>1 <= n <= 2 * 10<sup>5</sup></code></li>
 | 
						|
	<li><code>-10<sup>9</sup> <= nums[i] <= 10<sup>9</sup></code></li>
 | 
						|
</ul>
 |