1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-10 18:48:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/将数组划分成若干好子数组的方式 [ways-to-split-array-into-good-subarrays].html
2023-07-03 20:48:37 +08:00

37 lines
1.3 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>给你一个二元数组 <code>nums</code></p>
<p>如果数组中的某个子数组 <strong>恰好</strong> 只存在 <strong></strong> 个值为 <code>1</code> 的元素,则认为该子数组是一个 <strong>好子数组</strong></p>
<p>请你统计将数组 <code>nums</code> 划分成若干 <strong>好子数组</strong> 的方法数,并以整数形式返回。由于数字可能很大,返回其对 <code>10<sup>9</sup> + 7</code> <strong>取余 </strong>之后的结果。</p>
<p>子数组是数组中的一个连续 <strong>非空</strong> 元素序列。</p>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<pre><strong>输入:</strong>nums = [0,1,0,0,1]
<strong>输出:</strong>3
<strong>解释:</strong>存在 3 种可以将 nums 划分成若干好子数组的方式:
- [0,1] [0,0,1]
- [0,1,0] [0,1]
- [0,1,0,0] [1]
</pre>
<p><strong>示例 2</strong></p>
<pre><strong>输入:</strong>nums = [0,1,0]
<strong>输出:</strong>1
<strong>解释:</strong>存在 1 种可以将 nums 划分成若干好子数组的方式:
- [0,1,0]
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= nums.length &lt;= 10<sup>5</sup></code></li>
<li><code>0 &lt;= nums[i] &lt;= 1</code></li>
</ul>