Given a 0-indexed integer array nums of length n, a split at index i (0 <= i < n - 1) is valid when the sum of the first i + 1 elements is greater than or equal to the sum of the remaining elements. Return the number of valid splits.
Given a 0-indexed integer array nums of length n, a split at index i (0 <= i < n - 1) is valid when the sum of the first i + 1 elements is greater than or equal to the sum of the remaining elements. Return the number of valid splits.
Example 1:
Input: {"nums":[10,4,-8,7]}
Output: 2
Constraints:
2≤nums.length≤105
−105≤nums[i]≤105
Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result
Run code to see results.
Input
arr ={"nums":[10,4,-8,7]}
Put every element on the right pan first: total = 13. Moving the split one step right shifts one element from the right pan to the left pan.