Class Solution
java.lang.Object
g2301_2400.s2348_number_of_zero_filled_subarrays.Solution
2348 - Number of Zero-Filled Subarrays.<p>Medium</p>
<p>Given an integer array <code>nums</code>, return <em>the number of <strong>subarrays</strong> filled with</em> <code>0</code>.</p>
<p>A <strong>subarray</strong> is a contiguous non-empty sequence of elements within an array.</p>
<p><strong>Example 1:</strong></p>
<p><strong>Input:</strong> nums = [1,3,0,0,2,0,0,4]</p>
<p><strong>Output:</strong> 6</p>
<p><strong>Explanation:</strong></p>
<p>There are 4 occurrences of [0] as a subarray.</p>
<p>There are 2 occurrences of [0,0] as a subarray.</p>
<p>There is no occurrence of a subarray with a size more than 2 filled with 0. Therefore, we return 6.</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> nums = [0,0,0,2,0,0]</p>
<p><strong>Output:</strong> 9</p>
<p><strong>Explanation:</strong></p>
<p>There are 5 occurrences of [0] as a subarray.</p>
<p>There are 3 occurrences of [0,0] as a subarray.</p>
<p>There is 1 occurrence of [0,0,0] as a subarray.</p>
<p>There is no occurrence of a subarray with a size more than 3 filled with 0. Therefore, we return 9.</p>
<p><strong>Example 3:</strong></p>
<p><strong>Input:</strong> nums = [2,10,2019]</p>
<p><strong>Output:</strong> 0</p>
<p><strong>Explanation:</strong> There is no subarray filled with 0. Therefore, we return 0.</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 <= nums.length <= 10<sup>5</sup></code></li>
<li><code>-10<sup>9</sup> <= nums[i] <= 10<sup>9</sup></code></li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
zeroFilledSubarray
public long zeroFilledSubarray(int[] nums)
-