2023-12-09 18:42:21 +08:00
|
|
|
|
<p>给你一个按 <strong>非递减顺序</strong> 排列的整数数组 <code>nums</code> 。</p>
|
2022-03-27 20:46:41 +08:00
|
|
|
|
|
2023-12-09 18:42:21 +08:00
|
|
|
|
<p>请你判断是否能在将 <code>nums</code> 分割成 <strong>一个或多个子序列</strong> 的同时满足下述 <strong>两个</strong> 条件:</p>
|
2022-03-27 20:46:41 +08:00
|
|
|
|
|
2023-12-09 18:42:21 +08:00
|
|
|
|
<div class="original__bRMd">
|
|
|
|
|
<div>
|
|
|
|
|
<ul>
|
|
|
|
|
<li>每个子序列都是一个 <strong>连续递增序列</strong>(即,每个整数 <strong>恰好</strong> 比前一个整数大 <strong>1</strong> )。</li>
|
|
|
|
|
<li>所有子序列的长度 <strong>至少</strong> 为 <code>3</code><strong> </strong>。</li>
|
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
|
|
<p>如果可以分割 <code>nums</code> 并满足上述条件,则返回 <code>true</code> ;否则,返回 <code>false</code> 。</p>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<p> </p>
|
2022-03-27 20:46:41 +08:00
|
|
|
|
|
2023-12-09 18:42:21 +08:00
|
|
|
|
<p><strong class="example">示例 1:</strong></p>
|
2022-03-27 20:46:41 +08:00
|
|
|
|
|
|
|
|
|
<pre>
|
2023-12-09 18:42:21 +08:00
|
|
|
|
<strong>输入:</strong>nums = [1,2,3,3,4,5]
|
|
|
|
|
<strong>输出:</strong>true
|
|
|
|
|
<strong>解释:</strong>nums 可以分割成以下子序列:
|
|
|
|
|
[<em><strong>1</strong></em>,<em><strong>2</strong></em>,<em><strong>3</strong></em>,3,4,5] --> 1, 2, 3
|
|
|
|
|
[1,2,3,<em><strong>3</strong></em>,<em><strong>4</strong></em>,<em><strong>5</strong></em>] --> 3, 4, 5
|
2022-03-27 20:46:41 +08:00
|
|
|
|
</pre>
|
|
|
|
|
|
2023-12-09 18:42:21 +08:00
|
|
|
|
<p><strong class="example">示例 2:</strong></p>
|
2022-03-27 20:46:41 +08:00
|
|
|
|
|
|
|
|
|
<pre>
|
2023-12-09 18:42:21 +08:00
|
|
|
|
<strong>输入:</strong>nums = [1,2,3,3,4,4,5,5]
|
|
|
|
|
<strong>输出:</strong>true
|
|
|
|
|
<strong>解释:</strong>nums 可以分割成以下子序列:
|
|
|
|
|
[<em><strong>1</strong></em>,<em><strong>2</strong></em>,<em><strong>3</strong></em>,3,<em><strong>4</strong></em>,4,<em><strong>5</strong></em>,5] --> 1, 2, 3, 4, 5
|
|
|
|
|
[1,2,3,<em><strong>3</strong></em>,4,<em><strong>4</strong></em>,5,<em><strong>5</strong></em>] --> 3, 4, 5
|
2022-03-27 20:46:41 +08:00
|
|
|
|
</pre>
|
|
|
|
|
|
2023-12-09 18:42:21 +08:00
|
|
|
|
<p><strong class="example">示例 3:</strong></p>
|
2022-03-27 20:46:41 +08:00
|
|
|
|
|
|
|
|
|
<pre>
|
2023-12-09 18:42:21 +08:00
|
|
|
|
<strong>输入:</strong>nums = [1,2,3,4,4,5]
|
|
|
|
|
<strong>输出:</strong>false
|
|
|
|
|
<strong>解释:</strong>无法将 nums 分割成长度至少为 3 的连续递增子序列。
|
2022-03-27 20:46:41 +08:00
|
|
|
|
</pre>
|
|
|
|
|
|
2023-12-09 18:42:21 +08:00
|
|
|
|
<p> </p>
|
2022-03-27 20:46:41 +08:00
|
|
|
|
|
|
|
|
|
<p><b>提示:</b></p>
|
|
|
|
|
|
|
|
|
|
<ul>
|
2023-12-09 18:42:21 +08:00
|
|
|
|
<li><code>1 <= nums.length <= 10<sup>4</sup></code></li>
|
|
|
|
|
<li><code>-1000 <= nums[i] <= 1000</code></li>
|
|
|
|
|
<li><code>nums</code> 按非递减顺序排列</li>
|
2022-03-27 20:46:41 +08:00
|
|
|
|
</ul>
|