This can be solved in a pretty simple manner:
Just iterate over all possible positions for splitting the array, starting with an empty left array and right array is equal to the input-array and calculate the total sum of both chunks. Now simply move the first element in the array from the right to the left chunk. The total sums change in a pretty simple way: assume we remove n
from the right chunk, simply substract n
from the right chunk and add it the sum of the left chunk.
int equilibrium(int[] i)
int splitBefore = 0;
int left = 0;
int right = sumof(i);
for(; splitBefore < length(i) ; splitBefore++)
if(left == right)
return true;
left += i[splitBefore];
right -= i[splitBefore];
return left == right;