Search for a command to run...
You are given an integer array A of size N.
The stability score is defined as:
The number of indices i such that after removing element A[i], π Sum of elements at even indices = Sum of elements at odd indices
Important points:
After removing an element, the array re-indexes (shifts left)
So indices change β this is critical
Your task:
Return the total count of such indices
First line: Integer array A
A single integer β stability score
1β€Nβ€1051 \le N \le 10^51β€Nβ€105
1β€A[i]β€1041 \le A[i] \le 10^41β€A[i]β€104
Input:
2 1 6 4Output:
1Explanation: Remove index 1 β [2,6,4]
Even sum = 2 + 4 = 6
Odd sum = 6 β Balanced β count = 1
Example 1
[2, 1, 6, 4]1Example 2
[5, 5, 2, 5, 8]2[2, 1, 6, 4]
1