Fair Cuts
A cut splits nums into a left part and a right part that are both non-empty, so a cut sits between two neighboring positions. A cut is fair when the sum of the left part equals the sum of the right part.
Return how many fair cuts nums has. A list with fewer than two items has no cuts, so it gives 0.
Example 1
nums [1,2,3,3,3]
returns 1
Cutting after the third item gives [1, 2, 3] and [3, 3], both summing to 6. No other cut is fair.
Example 2
nums [0,0,0]
returns 2
Both cuts leave two parts summing to 0.
Constraints
0 <= len(nums) <= 100-1000 <= nums[i] <= 1000
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.