Find Pivot Index
- python
- prefix sum
Problem URL:Find Pivot Index
My Solution
Python
def pivotIndex(nums: List[int]) -> int:
for i in range(len(nums)):
if sum(nums[:i]) == sum(nums[i+1:]):
return i
return -1
Let's Connect
Twitter •GitHub •LinkedIn