values. Cut it into two non-empty parts, a front and a back. A cut is good if the sum of the front is at least the sum of the back.
Return the number of good cuts.values=[3, -1, 2, -4] → 3
The whole array sums to 0. After the first element it is 3 vs -3, after the second 2 vs -2, after the third 4 vs -4: all three cuts work.
values=[1, 5] → 0
The only cut gives 1 vs 5, so the left part is lighter.
values=[-2, -2, -2] → 1
Cutting after the first element gives -2 ≥ -4, which works. Cutting after the second gives -4 < -2, which does not.
values.length ≤ 10⁵values[i] ≤ 10⁵values=[3, -1, 2, -4]
3
Run checks the first 3 tests in your browser. Submit checks all 104 tests on the server, hidden ones included.