---
# System prepended metadata

title: 2750. Ways to Split Array Into Good Subarrays
tags: [Leetcode, Medium, Math]

---

Link: https://leetcode.com/problems/ways-to-split-array-into-good-subarrays/description/
## 思路
计算两个1中间间隔的0的数量
把所有数字+1然后乘起来就是答案
## Code
```python=
class Solution:
    def numberOfGoodSubarraySplits(self, nums: List[int]) -> int:
        lastCount, currCount = -1, 0
        ans = 1
        if max(nums)==0: return 0 
        for i in range(len(nums)):
            if nums[i]==0: currCount += 1
            else:
                if lastCount!=-1 and currCount!=1:
                    ans = (ans*lastCount*currCount)%(1e9+7)
                    ans = int(ans)
                lastCount = currCount
                currCount = 1
        return ans
```