LeetCode solutions

2432. Number of Zero-Filled Subarrays

My accepted Python solution to LeetCode problem 2432, Number of Zero-Filled Subarrays, running in 28ms.

  • Difficulty: Medium
  • Python
  • Runtime 28ms
  • Memory 28.7MB

Read the problem on LeetCode View on GitHub

Python

Accepted on LeetCode — runtime 28ms, memory 28.7MB, accepted 2025-12-29.

python
class Solution:
    def zeroFilledSubarray(self, nums: List[int]) -> int:
        result = 0
        count = 0
        
        for num in nums:
            if num == 0:
                count += 1
                result += count
            else:
                count = 0
        
        return result

Source