SHARE
TWEET

Untitled

a guest Jul 17th, 2017 41 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def solution(A):
  2.     # write your code in Python 2.7    
  3.     LeftSum=0
  4.     RightSum=sum(A)-A[0]
  5.    
  6.     EquilArray=[]
  7.     N=len(A)
  8.    
  9.     for i in range(N-1):
  10.         LeftSum+=A[i]
  11.         RightSum-=A[i+1]
  12.         #print LeftSum,RightSum
  13.         if LeftSum==RightSum:
  14.             EquilArray.append(i+1)
  15.  
  16.     if len(EquilArray)==0:
  17.         return -1
  18.     else:
  19.         return EquilArray
  20.  
  21.     pass
RAW Paste Data
Top