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