Find index such that sum of left sub-array = right sub-array (Equilibrium Index)

For a given array, we need to find an index such that sum of left sub-array = right sub-array also called the Equilibrium Index.
Equilibrium index is the index of the element in the array such that the sum of all the elements left to the index is equal to the sum of all the elements right to the index .

(A[0] + A[1] + … + A[i-1]) = (A[i+1] + A[i+2] + … + A[n-1]), where 0

2-1

input:
[3, 4, 1, 5, 2, 6]
output:
3
Explanation:
The left and right sub array for index '3' is [3, 4, 1] and [2, 6] respecti...

 •  0 comments  •  flag
Share on Twitter
Published on June 01, 2021 09:20
No comments have been added yet.