A split of an integer array is good if:
left, mid, right respectively from left to right.left is less than or equal to the sum of the elements in mid, and the sum of the elements in mid is less than or equal to the sum of the elements in right.Given nums, an array of non-negative integers, return the number of good ways to split nums. As the number may be too large, return it modulo 109 + 7.
Example 1:
Input: nums = [1,1,1] Output: 1 Explanation: The only good way to split nums is [1] [1] [1].
Example 2:
Input: nums = [1,2,2,2,5,0] Output: 3 Explanation: There are three good ways of splitting nums: [1] [2] [2,2,5,0] [1] [2,2] [2,5,0] [1,2] [2,2] [5,0]
Example 3:
Input: nums = [3,2,1] Output: 0 Explanation: There is no good way to split nums.
Constraints:
3 <= nums.length <= 1050 <= nums[i] <= 104Solutions for this problem are being prepared.
Try solving it yourselfBS 19. Painter's Partition and Split Array - Largest Sum • take U forward • 150,599 views views
Watch 9 more video solutions →Practice Ways to Split Array Into Three Subarrays with our built-in code editor and test cases.
Practice on FleetCode