Company: Aveva_24oct
Difficulty: medium
Fair Indexes Problem Description You are given two arrays A and B consisting of N integers each. Index K is named fair if the four sums [A[0] + ... + A[K-1]], [A[K] + ... + A[N-1]], [B[0] + ... + B[K-1]] and [B[K] + ... + B[N-1]] are all equal. In other words, K is the index where the two arrays, A and B, can be split (into two non-empty arrays each) in such a way that the sums of the resulting arrays' elements are equal. For example, given arrays A = [0, 4, -1, 0, 3] and B = [0, -2, 5, 0, 3], index K = 3 is fair. 0 1 2 3 4 A | 0 | 4 | -1| 0 | 3 | B | 0 | -2| 5 | 0 | 3 | K=3 Explanation: The sums of the four subarrays are all equal: 0 + 4 + (-1) = 3; 0 + 3 = 3; 0 + (-2) + 5 = 3 and 0 + 3 = 3. On the other hand, index K = 2 is not fair , the sums of the subarrays are: 0 + 4 = 4; (-1) + 0 + 3 = 2; 0 + (-2) = -2 and 5 + 0 + 3 = 8. Write a function: int solution(vector<int> &A, vector<int> &B); which, given two arrays A and B, returns the total number of fair indexes. E