Hi there,
i have a task, to write function in php.
Who can help me?
There is a task:
Equilibrium (EQ) Index of a sequence (array) is an index such that the sum of elements at lower indexes is equal to the sum of elements at higher indexes.
For example, in array A:
Array:
A[0] = -7
A[1] = 1
A[2] = 5
A[3] = 2
A[4] = -4
A[5] = 3
A[6] = 0
3 is an EQ index, beacuse: A[0] + A[1] + A[2] = A[4] + A[5] + A[6]
6 is also EQ index, coz: A[0] + A[1] + A[2] + A[3] + A[4] + A[5] = 0
(sum of zero elements is zero) 7 is not an EQ index, because it is not a valid index of array A
Assume the sum of zero elements is equal zero. Write a function.