|
| 1 | +<h2><a href="https://leetcode.com/problems/split-array-largest-sum">410. Split Array Largest Sum</a></h2><h3>Hard</h3><hr><p>Given an integer array <code>nums</code> and an integer <code>k</code>, split <code>nums</code> into <code>k</code> non-empty subarrays such that the largest sum of any subarray is <strong>minimized</strong>.</p> |
| 2 | + |
| 3 | +<p>Return <em>the minimized largest sum of the split</em>.</p> |
| 4 | + |
| 5 | +<p>A <strong>subarray</strong> is a contiguous part of the array.</p> |
| 6 | + |
| 7 | +<p> </p> |
| 8 | +<p><strong class="example">Example 1:</strong></p> |
| 9 | + |
| 10 | +<pre> |
| 11 | +<strong>Input:</strong> nums = [7,2,5,10,8], k = 2 |
| 12 | +<strong>Output:</strong> 18 |
| 13 | +<strong>Explanation:</strong> There are four ways to split nums into two subarrays. |
| 14 | +The best way is to split it into [7,2,5] and [10,8], where the largest sum among the two subarrays is only 18. |
| 15 | +</pre> |
| 16 | + |
| 17 | +<p><strong class="example">Example 2:</strong></p> |
| 18 | + |
| 19 | +<pre> |
| 20 | +<strong>Input:</strong> nums = [1,2,3,4,5], k = 2 |
| 21 | +<strong>Output:</strong> 9 |
| 22 | +<strong>Explanation:</strong> There are four ways to split nums into two subarrays. |
| 23 | +The best way is to split it into [1,2,3] and [4,5], where the largest sum among the two subarrays is only 9. |
| 24 | +</pre> |
| 25 | + |
| 26 | +<p> </p> |
| 27 | +<p><strong>Constraints:</strong></p> |
| 28 | + |
| 29 | +<ul> |
| 30 | + <li><code>1 <= nums.length <= 1000</code></li> |
| 31 | + <li><code>0 <= nums[i] <= 10<sup>6</sup></code></li> |
| 32 | + <li><code>1 <= k <= min(50, nums.length)</code></li> |
| 33 | +</ul> |
0 commit comments