


n = 4, A = {2, 4, 5, 1}, B = {3, 3, 10, -4}
Now in this example, if we split the array at index 1 then the sum of all the subarrays is 2 + 4 = 6, 5 + 1 = 6, 3 + 3 = 6, 10 + (-4) = 6, and no other index satisfies this condition, hence the answer is 1.
The first line of input format contains ‘T’, denoting the number of test cases. Then each test case follows.
The first line of each test case contains an integer ‘n’, Denoting the number of elements in the array A and B.
The second line of the test case contains an array of ‘n’ integers denoting the elements of array A.
The third line of the test case contains an array of ‘n’ integers denoting the elements of array B.
For each test case, print a single integer “ans” denoting the maximum number of indexes satisfying the given condition.
Output for every query will be printed in a separate line.
You are not required to print anything explicitly. It has already been taken care of. Just implement the functions.
1 <= T <= 100
2 <= N <= 10^5
-10^9 <= A[i], B[i] <= 10^9
Time Limit: 1 second
The approach is simple:
Start from the first element of the array till the last element of the array and check whether the sum of first i numbers equals the sum of the last n-i numbers for both the arrays.
The steps are as following:
In this approach, we will iterate through the array of strings and precompute the values of each index of array A and B and then iterate in the array to check the sum of all the indexes.
The steps are as following: