|
| 1 | +<h2><a href="https://leetcode.com/problems/number-of-zero-filled-subarrays">2432. Number of Zero-Filled Subarrays</a></h2><h3>Medium</h3><hr><p>Given an integer array <code>nums</code>, return <em>the number of <strong>subarrays</strong> filled with </em><code>0</code>.</p> |
| 2 | + |
| 3 | +<p>A <strong>subarray</strong> is a contiguous non-empty sequence of elements within an array.</p> |
| 4 | + |
| 5 | +<p> </p> |
| 6 | +<p><strong class="example">Example 1:</strong></p> |
| 7 | + |
| 8 | +<pre> |
| 9 | +<strong>Input:</strong> nums = [1,3,0,0,2,0,0,4] |
| 10 | +<strong>Output:</strong> 6 |
| 11 | +<strong>Explanation:</strong> |
| 12 | +There are 4 occurrences of [0] as a subarray. |
| 13 | +There are 2 occurrences of [0,0] as a subarray. |
| 14 | +There is no occurrence of a subarray with a size more than 2 filled with 0. Therefore, we return 6.</pre> |
| 15 | + |
| 16 | +<p><strong class="example">Example 2:</strong></p> |
| 17 | + |
| 18 | +<pre> |
| 19 | +<strong>Input:</strong> nums = [0,0,0,2,0,0] |
| 20 | +<strong>Output:</strong> 9 |
| 21 | +<strong>Explanation: |
| 22 | +</strong>There are 5 occurrences of [0] as a subarray. |
| 23 | +There are 3 occurrences of [0,0] as a subarray. |
| 24 | +There is 1 occurrence of [0,0,0] as a subarray. |
| 25 | +There is no occurrence of a subarray with a size more than 3 filled with 0. Therefore, we return 9. |
| 26 | +</pre> |
| 27 | + |
| 28 | +<p><strong class="example">Example 3:</strong></p> |
| 29 | + |
| 30 | +<pre> |
| 31 | +<strong>Input:</strong> nums = [2,10,2019] |
| 32 | +<strong>Output:</strong> 0 |
| 33 | +<strong>Explanation:</strong> There is no subarray filled with 0. Therefore, we return 0. |
| 34 | +</pre> |
| 35 | + |
| 36 | +<p> </p> |
| 37 | +<p><strong>Constraints:</strong></p> |
| 38 | + |
| 39 | +<ul> |
| 40 | + <li><code>1 <= nums.length <= 10<sup>5</sup></code></li> |
| 41 | + <li><code>-10<sup>9</sup> <= nums[i] <= 10<sup>9</sup></code></li> |
| 42 | +</ul> |
0 commit comments