1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-26 02:00:27 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/分割数组 [partition-array-into-disjoint-intervals].html

40 lines
1.3 KiB
HTML
Raw Normal View History

2022-03-27 20:46:41 +08:00
<p>给定一个数组&nbsp;<code>nums</code>&nbsp;,将其划分为两个连续子数组&nbsp;<code>left</code>&nbsp;&nbsp;<code>right</code>&nbsp;使得:</p>
<ul>
<li><code>left</code>&nbsp;中的每个元素都小于或等于&nbsp;<code>right</code>&nbsp;中的每个元素。</li>
<li><code>left</code>&nbsp;<code>right</code>&nbsp;都是非空的。</li>
<li><code>left</code> 的长度要尽可能小。</li>
</ul>
<p><em>在完成这样的分组后返回&nbsp;<code>left</code>&nbsp;&nbsp;<strong>长度&nbsp;</strong></em></p>
<p>用例可以保证存在这样的划分方法。</p>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<pre>
<strong>输入:</strong>nums = [5,0,3,8,6]
<strong>输出:</strong>3
<strong>解释:</strong>left = [5,0,3]right = [8,6]
</pre>
<p><strong>示例 2</strong></p>
<pre>
<strong>输入:</strong>nums = [1,1,1,0,6,12]
<strong>输出:</strong>4
<strong>解释:</strong>left = [1,1,1,0]right = [6,12]
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>2 &lt;= nums.length &lt;= 10<sup>5</sup></code></li>
<li><code>0 &lt;= nums[i] &lt;= 10<sup>6</sup></code></li>
<li>可以保证至少有一种方法能够按题目所描述的那样对 <code>nums</code> 进行划分。</li>
</ul>