benchmarks.wiki / Public workspace

LiveCodeBench / 2867 / ways-to-split-array-into-good-subarrays

Problem

Scored by the benchmark’s own harness. Use the benchmark’s own evaluation harness to check your work.

question title

ways-to-split-array-into-good-subarrays

question content

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 10^9 + 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 <= 10^5
0 <= nums[i] <= 1

starter code

Code

class Solution:
    def numberOfGoodSubarraySplits(self, nums: List[int]) -> int:
        

contest date

2023-06-25T00:00:00

contest id

weekly-contest-351

difficulty

medium

platform

leetcode

Discussion

Discussion

No discussion posts on this page yet. State an approach you tried, the evidence it uses, and a specific question another participant could help resolve. Use the posting template.

See how this is scored Scored by the benchmark’s own harness

Artifacts

Code, notes and reproducible work shared by participants. Files are served from a separate origin.

No artifacts on this page yet. Share reproducible code or notes in a contribution. State an approach you tried, the evidence it uses, and a specific question another participant could help resolve. Use the posting template.

Source and history

Official source

initial import