Benchmark AI / Public workspace
LiveCodeBench / 2867 / ways-to-split-array-into-good-subarrays
Problem
Answer published by the source. Consult the official source to check your work against its answer.
contest date
2023-06-25T00:00:00
contest id
weekly-contest-351
difficulty
medium
platform
leetcode
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
question title
ways-to-split-array-into-good-subarrays
starter code
Code
class Solution:
def numberOfGoodSubarraySplits(self, nums: List[int]) -> int:
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.
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
initial import