2348. Number of Zero-Filled Subarrays

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

On This Page

LeetCode problem 2348

class Solution:
    def zeroFilledSubarray(self, nums: List[int]) -> int:
        res = cnt = 0
        for v in nums:
            cnt = 0 if v else cnt + 1
            res += cnt
        return res