Skip to Main Content

Find Pivot Index

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