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)/递增的三元子序列 [increasing-triplet-subsequence].html
2022-03-29 12:43:11 +08:00

42 lines
1.4 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

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>给你一个整数数组&nbsp;<code>nums</code> ,判断这个数组中是否存在长度为 <code>3</code> 的递增子序列。</p>
<p>如果存在这样的三元组下标 <code>(i, j, k)</code>&nbsp;且满足 <code>i &lt; j &lt; k</code> ,使得&nbsp;<code>nums[i] &lt; nums[j] &lt; nums[k]</code> ,返回 <code>true</code> ;否则,返回 <code>false</code></p>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<pre>
<strong>输入:</strong>nums = [1,2,3,4,5]
<strong>输出:</strong>true
<strong>解释:</strong>任何 i &lt; j &lt; k 的三元组都满足题意
</pre>
<p><strong>示例 2</strong></p>
<pre>
<strong>输入:</strong>nums = [5,4,3,2,1]
<strong>输出:</strong>false
<strong>解释:</strong>不存在满足题意的三元组</pre>
<p><strong>示例 3</strong></p>
<pre>
<strong>输入:</strong>nums = [2,1,5,0,4,6]
<strong>输出:</strong>true
<strong>解释:</strong>三元组 (3, 4, 5) 满足题意,因为 nums[3] == 0 &lt; nums[4] == 4 &lt; nums[5] == 6
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= nums.length &lt;= 5 * 10<sup>5</sup></code></li>
<li><code>-2<sup>31</sup> &lt;= nums[i] &lt;= 2<sup>31</sup> - 1</code></li>
</ul>
<p>&nbsp;</p>
<p><strong>进阶:</strong>你能实现时间复杂度为 <code>O(n)</code> ,空间复杂度为 <code>O(1)</code> 的解决方案吗?</p>