2578. Split With Minimum SumEasy Topics Companies Hint Given a positive integer num, split it into two non-negative integers num1 and num2 such that: The concatenation of num1 and num2 is a permutation of num. In other words, the sum of the number of occurrences of each digit in ...
where the largest sum among the two subarrays is only 18. 题解: Let dp[i][j] denotes up to index j, with i cut, the minimum of largest sum of subarrays. Thus with i = 0, that means there is no cut. Initialize dp[0][j] as sum of nums[0] to nums[j]. For dp[i][j],...
Since we need to compute subarray sum, so we should get the prefix sum array ps. Notice that nums[i] is nonnegative, so ps is non-decreasing. Using ps we can either do a linear scan with binary search, or just a linear scan. Solution 1. O(N*logN), fix the start index of the ...
If we can't, it is either we successfully divide the array into m parts and the sum of each part is less than mid, or we used up all numbers before we reach m. Both of them mean that we should lower mid because we need to find the minimum one. This leads to r = mid - 1; ...