mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-10 18:48:13 +08:00
38 lines
1.2 KiB
HTML
38 lines
1.2 KiB
HTML
<p>给你一个整数数组 <code>arr</code>,只有可以将其划分为三个和相等的 <strong>非空</strong> 部分时才返回 <code>true</code>,否则返回 <code>false</code>。</p>
|
||
|
||
<p>形式上,如果可以找出索引 <code>i + 1 < j</code> 且满足 <code>(arr[0] + arr[1] + ... + arr[i] == arr[i + 1] + arr[i + 2] + ... + arr[j - 1] == arr[j] + arr[j + 1] + ... + arr[arr.length - 1])</code> 就可以将数组三等分。</p>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong>示例 1:</strong></p>
|
||
|
||
<pre>
|
||
<strong>输入:</strong>arr = [0,2,1,-6,6,-7,9,1,2,0,1]
|
||
<strong>输出:</strong>true
|
||
<strong>解释:</strong>0 + 2 + 1 = -6 + 6 - 7 + 9 + 1 = 2 + 0 + 1
|
||
</pre>
|
||
|
||
<p><strong>示例 2:</strong></p>
|
||
|
||
<pre>
|
||
<strong>输入:</strong>arr = [0,2,1,-6,6,7,9,-1,2,0,1]
|
||
<strong>输出:</strong>false
|
||
</pre>
|
||
|
||
<p><strong>示例 3:</strong></p>
|
||
|
||
<pre>
|
||
<strong>输入:</strong>arr = [3,3,6,5,-2,2,5,1,-9,4]
|
||
<strong>输出:</strong>true
|
||
<strong>解释:</strong>3 + 3 = 6 = 5 - 2 + 2 + 5 + 1 - 9 + 4
|
||
</pre>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong>提示:</strong></p>
|
||
|
||
<ul>
|
||
<li><code>3 <= arr.length <= 5 * 10<sup>4</sup></code></li>
|
||
<li><code>-10<sup>4</sup> <= arr[i] <= 10<sup>4</sup></code></li>
|
||
</ul>
|