[Copy question]:
Given an array which consists of non-negative integers and a integer m, you can split the array into m Non-empty continuous subarrays. Write a algorithm to minimize the largest sum among these m subarrays.
Note:
If N is the length of an array, assume the following constraints is satisfied:
- 1 ≤ n ≤1000
- 1 ≤ m ≤min ( n)
Examples:
Input:nums = [7,2,5,10,8]m = 2output:18explanation:there is four ways to split nums into and Subarrays. The best-of-the-is-to-split it into [7,2,5] and [10,8],where the largest sum among the "the" and "is" only 18.
[Brute force solution]:
Time Analysis:
Spatial Analysis:
[After optimization]:
Time Analysis:
Spatial Analysis:
[Wonderful output CONDITIONS]:
[Wonderful corner case]:
[Thinking questions]:
I don't know why. Using dichotomy: dichotomy can find a position by moving mid
[English data structure or algorithm, why not other data structures or algorithms]:
[a sentence of thought]:
Unexpectedly: The largest number must be separated, see can be left to draw several numbers and it a group
[7,2,5,10,8,105550]3 return 105550
Group no more than M, extend left or right
[input]: null: Normal: Large: Extra Small: Special cases handled in the program: abnormal conditions (unreasonable input):
[Drawing]:
[One brush]:
[Two brushes]:
[Three brushes]:
[Four brushes]:
[Five brushes]:
[Results of five-minute visual debug]:
[Summary]:
Try a few more , and you'll see.
[Complexity]:time Complexity:o () Space complexity:o ()
[Algorithmic thinking: Recursion/division/greed]:
[Key templating code]:
[Other solutions]:
[Follow up]:
[The problem given by the LC becomes variable]:
[Code Style]:
[Whether to write this type of driver Funcion code for the first time]:
410. Split array largest Sum divides the array into M-groups, how to make the maximum and minimum