Info

What tricked me up about this problem was starting res at 1 and the zero_counter at 1 (the devil is in the details). This is because of the case 00011, in which you can isolate the 1 into sections of the form: [0001] and [1] which thereby adds an extra case.

class Solution:
    def numberOfGoodSubarraySplits(self, nums: List[int]) -> int:
        count = Counter(nums)
        if 1 not in count:
            return 0
        if count[1] == 1:
            return 1
    
        seen_one = False
        zero_counter = 1
        res = 1
        for num in nums:
            if num == 1:
                if not seen_one:
                    seen_one = True
                else:
                    res *= zero_counter
                    res %= 10 ** 9 + 7
                    zero_counter = 1
            elif seen_one:
                zero_counter += 1
 
        return res

References

https://leetcode.com/problems/ways-to-split-array-into-good-subarrays/