Find Pivot Index

  • 0

    Click here to see the full article post

  • 1

    def pivotIndex(self, nums):
    right_sum, left_sum = sum(nums), 0
    for i in range(len(nums)):
    right_sum -= nums[i]
    if left_sum == right_sum:
    return i
    left_sum += nums[i]
    return -1

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.