Simple python solution


  • -1
        def pivotIndex(self, nums):
            arr_sum, left_sum = sum(nums), 0
            for i in range(len(nums)):
                arr_sum -= nums[i]
                if left_sum == arr_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.