Split Array Largest Sum(二分,dp?)
Given an array which consists of non-negative integers and an integerm, you can split the array intomnon-empty continuous subarrays. Write an algorithm to minimize the largest sum among thesemsubarrays.
Note: If n is the length of array, assume the following constraints are satisfied:
Examples:
分析:
看成找一个target,使得分成的m个subarray的sum都<=target,所以用二分,这个target在max(nums)和sum(nums)之间。在这个区间左右移动算是已排序数组。
辅助函数中cnt是切下去的刀数。刀数+1 = group数目
这里二分不知道边界怎么做了
dp:前面j组和i结尾,然后j,i之间开始切分最后一组。有点类似背包最后一个value开分。
Python可以 python3不行
PreviousConvert Binary Search Tree to Sorted Doubly Linked List (Tree)NextSum of Left Leaves(递归和分治,dfs,树)
Last updated