Given an array which consists of non-negative integers and an integer m, you can split the array into m non-empty continuous subarrays. Write an algorithm to minimize the largest sum among these m subarrays.
Note: Given m satisfies the following constraint: 1 ≤ m ≤ length(nums) ≤ 14,000.
Examples:
1
2
3
4
5
6
7
8
9
10
11
Input:
nums = [1,2,3,4,5]
m = 2
Output:
9
Explanation:
There are four ways tosplit nums intotwo subarrays.
The best way is tosplititinto [1,2,3] and [4,5],
where the largest sumamongthetwo subarrays is only 9.