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)/将数组分成三个子数组的方案数 [ways-to-split-array-into-three-subarrays].html
2022-03-29 12:43:11 +08:00

45 lines
1.4 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>我们称一个分割整数数组的方案是 <strong>好的</strong> ,当它满足:</p>
<ul>
<li>数组被分成三个 <strong>非空</strong> 连续子数组,从左至右分别命名为 <code>left</code>  <code>mid</code>  <code>right</code> 。</li>
<li><code>left</code> 中元素和小于等于 <code>mid</code> 中元素和,<code>mid</code> 中元素和小于等于 <code>right</code> 中元素和。</li>
</ul>
<p>给你一个 <strong>非负</strong> 整数数组 <code>nums</code> ,请你返回 <strong>好的</strong> 分割 <code>nums</code> 方案数目。由于答案可能会很大,请你将结果对 <code>10<sup>9 </sup>+ 7</code> 取余后返回。</p>
<p> </p>
<p><strong>示例 1</strong></p>
<pre>
<b>输入:</b>nums = [1,1,1]
<b>输出:</b>1
<b>解释:</b>唯一一种好的分割方案是将 nums 分成 [1] [1] [1] 。</pre>
<p><strong>示例 2</strong></p>
<pre>
<b>输入:</b>nums = [1,2,2,2,5,0]
<b>输出:</b>3
<b>解释:</b>nums 总共有 3 种好的分割方案:
[1] [2] [2,2,5,0]
[1] [2,2] [2,5,0]
[1,2] [2,2] [5,0]
</pre>
<p><strong>示例 3</strong></p>
<pre>
<b>输入:</b>nums = [3,2,1]
<b>输出:</b>0
<b>解释:</b>没有好的分割方案。</pre>
<p> </p>
<p><strong>提示:</strong></p>
<ul>
<li><code>3 <= nums.length <= 10<sup>5</sup></code></li>
<li><code>0 <= nums[i] <= 10<sup>4</sup></code></li>
</ul>