1991. Find the Middle Index in Array
Содержание
class Solution:
def findMiddleIndex(self, nums: List[int]) -> int:
left, right = 0, sum(nums)
for i, x in enumerate(nums):
right -= x
if left == right:
return i
left += x
return -1