Download Find Pivot Index.py
class Solution(object): def pivotIndex(self, nums): """ :type nums: List[int] :rtype: int """ totalsum = sum(nums) leftsum = 0 for i, v in enumerate(nums): # leftsum == rightsum if leftsum == totalsum - leftsum - v: return i leftsum += v return -1
Leetcode 724 Find Pivot Index problem solution in python3 with explanation. This is the best place to expand your knowledge and get prepared for your next interview.
Feedback is the most important part of any website.
If you have any query, suggestion or feedback, Please feel free to contact us.