Loading...
You are given an integer array nums.
An index i is a balance point when the sum of the values strictly to its left equals the sum of the values strictly to its right. The value at i itself belongs to neither side.
At index 0 there is nothing to the left, so the left sum is 0; the same applies at the last index for the right sum.
Return the leftmost balance point, or -1 if the array has none.
Input: nums = [1,7,3,6,5,6]
Output: 3
Explanation: At index 3 the left sum is 1 + 7 + 3 = 11 and the right sum is 5 + 6 = 11. No smaller index balances.
Input: nums = [1,2,3]
Output: -1
Explanation: No index has equal sums on both sides.
Input: nums = [2,1,-1]
Output: 0
Explanation: At index 0 the left sum is 0 (nothing is to the left) and the right sum is 1 + (-1) = 0.
nums.length ≤104nums[i] ≤1000Click "Run" to test with sample cases or "Submit" to run all tests.