Description: Given an array A of n integers, count the number of ways to split the elements of the array into exactly 3 contiguous parts such that the sum of each part is the same. More formally, ﬁnd the number of indices i, j(2 <= i <= j <= n−1) such that,Pi−1 k=1 Ak =Pj−1 k=i Ak =Pn k=j Ak Input The ﬁrst line contains an integer n - the size of array. The next line contains n space separated integers - the elements of the array. Output Print a single integer - the number of ways to split the array. Constraints 1 <= n <= 106 |A[i]| <= 109 Sample Test Case

Input Output 5 2 1 2 3 0 3

Explanation 2 possible ways of trisecting [1 2 3 0 3] - [1 2], [3], [0 3] and [1 2], [3 0], [3]

Dear @Thirumaleswari_Banug

Is this question of any running contest? Can you give us the link of this question?

1 Like