1 class Solution(object): 2 def pivotIndex(self, nums): 3 """ 4 :type nums: List[int] 5 :rtype: int 6 """ 7 sumi = 0 8 s = sum(nums) 9 for i in range(len(nums)): 10 if 2 * sumi + nums[i] == s: 11 return i 12 sumi += nums[i] 13 return -1 14 15 16 if __name__ == '__main__': 17 solution = Solution() 18 print(solution.pivotIndex([-1, -1, 0, 1, 1, 0]))