Equilibrium index of an array
Equlibrium index of an 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 an array A: [-7, 1, 5, 2, -4, 3, 0], index 3 is an equilibrium index, because A[0] + A[1] + A[2] = A[4] + A[5] + A[6] = -1. 6 is also an equlibrium index.
这题解法用leftSum和totalSum来判断。
Last updated
Was this helpful?