values. Exactly one element is removed from it; the elements to its right shift one place to the left, so their indices drop by 1.
Call an array **balanced** if the sum of its elements at even indices equals the sum of its elements at odd indices (indices are 0-based).
Return the number of indices whose removal leaves the array balanced.values=[3, 5, 2, 4] → 1
Remove index 0: [5, 2, 4], even 5 + 4 = 9, odd 2. Index 1: [3, 2, 4], 7 and 2. Index 2: [3, 5, 4], 7 and 5. Index 3: [3, 5, 2], 5 and 5, equal. Only one index works.
values=[7, 7, 7, 7, 7] → 5
Removing any element leaves four 7s, and both sums are 14, so all 5 indices work.
values=[2, 9] → 0
values=[3, 5, 2, 4]
1
Run checks the first 3 tests in your browser. Submit checks all 101 tests on the server, hidden ones included.