Skip to Main Content

Find the Middle Index in Array

Problem URL:Find the Middle Index in Array

My Solution

Python

def findMiddleIndex(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