|
| 1 | +<h2><a href="https://leetcode.com/problems/partition-array-into-three-parts-with-equal-sum">Partition Array Into Three Parts With Equal Sum</a></h2> <img src='https://img.shields.io/badge/Difficulty-Easy-brightgreen' alt='Difficulty: Easy' /><hr><p>Given an array of integers <code>arr</code>, return <code>true</code> if we can partition the array into three <strong>non-empty</strong> parts with equal sums.</p> |
| 2 | + |
| 3 | +<p>Formally, we can partition the array if we can find indexes <code>i + 1 < j</code> with <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> |
| 4 | + |
| 5 | +<p> </p> |
| 6 | +<p><strong class="example">Example 1:</strong></p> |
| 7 | + |
| 8 | +<pre> |
| 9 | +<strong>Input:</strong> arr = [0,2,1,-6,6,-7,9,1,2,0,1] |
| 10 | +<strong>Output:</strong> true |
| 11 | +<strong>Explanation: </strong>0 + 2 +たす 1 =わ -ひく6 +たす 6 -ひく 7 +たす 9 +たす 1 =わ 2 +たす 0 +たす 1 |
| 12 | +</pre> |
| 13 | + |
| 14 | +<p><strong class="example">Example 2:</strong></p> |
| 15 | + |
| 16 | +<pre> |
| 17 | +<strong>Input:</strong> arr = [0,2,1,-6,6,7,9,-1,2,0,1] |
| 18 | +<strong>Output:</strong> false |
| 19 | +</pre> |
| 20 | + |
| 21 | +<p><strong class="example">Example 3:</strong></p> |
| 22 | + |
| 23 | +<pre> |
| 24 | +<strong>Input:</strong> arr = [3,3,6,5,-2,2,5,1,-9,4] |
| 25 | +<strong>Output:</strong> true |
| 26 | +<strong>Explanation: </strong>3 +たす 3 =わ 6 =わ 5 -ひく 2 +たす 2 +たす 5 +たす 1 -ひく 9 +たす 4 |
| 27 | +</pre> |
| 28 | + |
| 29 | +<p> </p> |
| 30 | +<p><strong>Constraints:</strong></p> |
| 31 | + |
| 32 | +<ul> |
| 33 | + <li><code>3 <= arr.length <= 5 * 10<sup>4</sup></code></li> |
| 34 | + <li><code>-10<sup>4</sup> <= arr[i] <= 10<sup>4</sup></code></li> |
| 35 | +</ul> |
0 commit comments