Loading...
Loading...
Loading...
Print the first index i where the sum of the items before i equals the sum of the items after i. An empty side has sum 0. Print -1 when there is no such index.
Example
Input
5 2 4 9 3 3
Output
2
Left sum 6, right sum 6 at index 2.
Try the problem first. Open one hint at a time.
Keep a running sum of everything to the left.
The right sum is the total minus the left sum minus the current item.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor