Good Arrays Problem Statement
You are given an array 'A' of length 'N'. You must choose an element from any index in this array and delete it. After deleting the element, you will obtain a new array of length 'N'-1. Your task is to find the number of such arrays of length 'N'-1 that are considered 'good'.
Explanation:
An array is defined as 'good' if the sum of elements at odd indices is equal to the sum of elements at even indices.
Example:
Input:
N = 5
A = [1, 2, 4, 3, 6]
Output:
1
Explanation:
If you delete A[4]=6, the new array B = [1, 2, 4, 3] satisfies the condition: B[0] + B[2] = B[1] + B[3] = 5, thus making it a 'good' array.
Input:
The first line of the input contains 'T' denoting the number of test cases.
The first line of each test case contains an integer 'N', the length of the array.
The second line of each test case contains N space-separated integers of the array A.
Output:
For each test case, print an integer denoting the number of good arrays that can be formed.
Constraints:
- 1 <= T <= 5
- 1 <= N <= 3000
- -5000 <= A[i] <= 5000
- Time Limit: 1 sec
Note:
You do not need to print anything; it has already been taken care of. Just implement the given function to return the answer.

Given an array, find the number of 'good' arrays that can be formed by deleting one element.
Iterate through each element in the array and check if deleting it results in a 'good' array
Keep track of th...read more
Adobe Member Technical Staff interview questions & answers
Popular interview questions of Member Technical Staff


Reviews
Interviews
Salaries
Users

