1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-10 18:48:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/132 模式 [132-pattern].html
2022-03-29 12:43:11 +08:00

40 lines
1.3 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>给你一个整数数组 <code>nums</code> ,数组中共有 <code>n</code> 个整数。<strong>132 模式的子序列</strong> 由三个整数 <code>nums[i]</code><code>nums[j]</code><code>nums[k]</code> 组成,并同时满足:<code>i < j < k</code><code>nums[i] < nums[k] < nums[j]</code></p>
<p>如果 <code>nums</code> 中存在 <strong>132 模式的子序列</strong> ,返回 <code>true</code> ;否则,返回 <code>false</code></p>
<p> </p>
<p><strong>示例 1</strong></p>
<pre>
<strong>输入:</strong>nums = [1,2,3,4]
<strong>输出:</strong>false
<strong>解释:</strong>序列中不存在 132 模式的子序列。
</pre>
<p><strong>示例 2</strong></p>
<pre>
<strong>输入:</strong>nums = [3,1,4,2]
<strong>输出:</strong>true
<strong>解释:</strong>序列中有 1 个 132 模式的子序列: [1, 4, 2] 。
</pre>
<p><strong>示例 3</strong></p>
<pre>
<strong>输入:</strong>nums = [-1,3,2,0]
<strong>输出:</strong>true
<strong>解释:</strong>序列中有 3 个 132 模式的的子序列:[-1, 3, 2]、[-1, 3, 0] 和 [-1, 2, 0] 。
</pre>
<p> </p>
<p><strong>提示:</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>