Balance Point Index
Return the smallest index such that the sum of the elements to the left of equals the sum of the elements to its right (the element at belongs to neither side). Return -1 if there is none.
Requirements
- time with a running prefix sum.
Examples
EXAMPLE WALKTHROUGHmiddle
A guided view of the published example, not a trace of your code.
INPUT
[[1,7,3,6,5,6]]TASKbalance_point_index()
EXPECTED OUTPUT
3Start with the input values shown in this example.
Example 1 of 3
Input: nums = [1,7,3,6,5,6]
Output: 3
Explanation: middle
Input: nums = [1,2,3]
Output: -1
Explanation: none
Input: nums = [2,1,-1]
Output: 0
Explanation: first index
Hint 1
Right sum = total - left sum - nums[i].