Given a positive integer array partition array into M
subarray such that when we take sum of each subarray and chose maximum it is minimal across all subarray combinations.
I tried drawing all combinations when M=1
, M=2
... but couldn't find DP pattern. Some help will be greatly appreciated.
Input array : [7,2,3,4,5] and M = 3
Optimal partitioning : [7], [2,3,4], [5]
Answer Max(7, 2+3+4, 5) = 9
Input array : [4,3,2,2,2,6] and M = 3
Optimal partitioning : [4,3], [2,2,2], [6]
Answer Max(4+3, 2+2+2, 6) = 7