Examples
Example 1
Input: 10 4 -8 7
Output: 2
Example 2
Input: 2 3 1 0
Output: 2
Requirements
- You are given an array of integers.
- Pick a division point such that both the left portion and the right portion contain at least one element.
- Count every division for which
sum(left) is greater than sum(right).
- Return that total.
Notes
- Although negative values can make the sums less intuitive, they do not alter the approach; do not assume sums are monotonic unless non-negative inputs are guaranteed.
Preparation
- Check arrays containing negative values, arrays of only positive values, two-element arrays, and cases with zero qualifying cuts.