Tap here to switch tabs
Problem
Submissions

Problem: Ways to Split Array Into Good Subarrays

med
30 min
Try to solve the Ways to Split Array Into Good Subarrays problem.

Statement

You are given a binary array nums.

A subarray is defined as good if it contains exactly one element equal to 11.

A split of the array is valid if nums is partitioned into one or more contiguous non-empty subarrays where every subarray is good.

Return the total number of ways to split nums into good subarrays. Since the answer can be large, return it modulo 109+710^9 + 7. If there are no valid splits, return 00.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • 0≤0 \leq nums[i] ≤1\leq 1

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Ways to Split Array Into Good Subarrays

med
30 min
Try to solve the Ways to Split Array Into Good Subarrays problem.

Statement

You are given a binary array nums.

A subarray is defined as good if it contains exactly one element equal to 11.

A split of the array is valid if nums is partitioned into one or more contiguous non-empty subarrays where every subarray is good.

Return the total number of ways to split nums into good subarrays. Since the answer can be large, return it modulo 109+710^9 + 7. If there are no valid splits, return 00.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • 0≤0 \leq nums[i] ≤1\leq 1