Skip to content

Latest commit

 

History

History
75 lines (50 loc) · 1.34 KB

2750-ways-to-split-array-into-good-subarrays.adoc

File metadata and controls

75 lines (50 loc) · 1.34 KB

2750. Ways to Split Array Into Good Subarrays

{leetcode}/problems/ways-to-split-array-into-good-subarrays/[LeetCode - 2750. Ways to Split Array Into Good Subarrays ^]

You are given a binary array nums.

A subarray of an array is good if it contains exactly one element with the value 1.

Return an integer denoting the number of ways to split the array _`nums` into good subarrays_. As the number may be too large, return it modulo 109 + 7.

A subarray is a contiguous non-empty sequence of elements within an array.

Example 1:

Input: nums = [0,1,0,0,1]
Output: 3
Explanation: There are 3 ways to split nums into good subarrays:
- [0,1] [0,0,1]
- [0,1,0] [0,1]
- [0,1,0,0] [1]

Example 2:

Input: nums = [0,1,0]
Output: 1
Explanation: There is 1 way to split nums into good subarrays:
- [0,1,0]

Constraints:

  • 1 ⇐ nums.length ⇐ 105

  • 0 ⇐ nums[i] ⇐ 1

思路分析

一刷
link:{sourcedir}/_2750_WaysToSplitArrayIntoGoodSubarrays.java[role=include]

参考资料