1 class Solution: 2 def pivotIndex(self, nums: List[int]) -> int: 3 s = sum(nums) 4 left = 0 5 for i,num in enumerate(nums): 6 if 2 * left == s - num:return i 7 left += num 8 return -1
2023-10-23 19:53:40
1 class Solution: 2 def pivotIndex(self, nums: List[int]) -> int: 3 s = sum(nums) 4 left = 0 5 for i,num in enumerate(nums): 6 if 2 * left == s - num:return i 7 left += num 8 return -1