java.lang.Object
g0401_0500.s0410_split_array_largest_sum.Solution

public class Solution extends Object
410 - Split Array Largest Sum.<p>Hard</p> <p>Given an array <code>nums</code> which consists of non-negative integers and an integer <code>m</code>, you can split the array into <code>m</code> non-empty continuous subarrays.</p> <p>Write an algorithm to minimize the largest sum among these <code>m</code> subarrays.</p> <p><strong>Example 1:</strong></p> <p><strong>Input:</strong> nums = [7,2,5,10,8], m = 2</p> <p><strong>Output:</strong> 18</p> <p><strong>Explanation:</strong></p> <pre><code> There are four ways to split nums into two subarrays. 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. </code></pre> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> nums = [1,2,3,4,5], m = 2</p> <p><strong>Output:</strong> 9</p> <p><strong>Example 3:</strong></p> <p><strong>Input:</strong> nums = [1,4,4], m = 3</p> <p><strong>Output:</strong> 4</p> <p><strong>Constraints:</strong></p> <ul> <li><code>1 <= nums.length <= 1000</code></li> <li><code>0 <= nums[i] <= 10<sup>6</sup></code></li> <li><code>1 <= m <= min(50, nums.length)</code></li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • splitArray

      public int splitArray(int[] nums, int m)