2270. Number of Ways to Split Array

Updated: 2024-03-12
1 min read
[]

On This Page

LeetCode problem 2270

class Solution:
    def waysToSplitArray(self, nums: List[int]) -> int:
        s = sum(nums)
        res = t = 0
        for v in nums[:-1]:
            t += v
            if t >= s - t:
                res += 1
        return res