summaryrefslogtreecommitdiff
path: root/progs/a100.py
blob: 9236c703a4214970e5af388fb09607cae6cf7a37 (plain)
1
2
3
4
5
6
7
8
9
def equilibrium_index(arr):
  total_sum = sum(arr)
  left_sum=0
  for i, num in enumerate(arr):
    total_sum -= num
    if left_sum == total_sum:
      return i
    left_sum += num
  return -1