Array Equilibrium Index

Find and return the equilibrium index of an array. Equilibrium index of an array is an index i such that the sum of elements at indices less than i is equal to the sum of elements at indices greater than i.

If more than one equilibrium index is present, you need to return the first one. And return -1 if no equilibrium index is present.

Input format :

Line 1 : Size of input array

Line 2 : Array elements (separated by space)

Sample Input:
7
-7 1 5 2 -4 3 0
Output:
3 

Login to submit your solution

Fb dab53a1a64929320dc7425896aa73fd9e5512b6ab52e414ff5f3ebb5cecc73eb

Share Problem