You get an integer array nums. An index i is a pivot when the numbers before it add up to the same total as the numbers after it. nums[i] itself belongs to neither side.
At the ends, one side is empty and its total is 0: index 0 is a pivot when everything after it sums to 0, and the last index is a pivot when everything before it sums to 0.
Return the smallest pivot index, or -1 if no index is a pivot.
Index 0 sees 0 against 11, and index 1 sees 3 against 10. At index 2 both sides total 4, so the 6 in the middle is the pivot.
Indices 2 and 3 are both pivots, with 4 on each side. Return the smaller one.
The three indices give 0 vs 1, 2 vs -3 and 6 vs 0. None balance.
Constraints
1 <= nums.length <= 10⁴-1000 <= nums[i] <= 1000The right side's total is the whole array's total minus the left side's total minus nums[i], so you never need to add up the right side separately.
2