Count Partitions with Exactly Two Zeros Each
Problem Given a binary string, count the number of ways to partition it into contiguous substrings such that every substring contains exactly two 0s.
Input / Output
- Input: a string s of characters '0' and '1'.
- Output: the number of valid partitions. Return the count modulo 10^9+7 if it can overflow.
Constraints
- Length up to 10^5.
- Characters are only '0' or '1'.
- Every character must belong to exactly one piece — the pieces tile the whole string.
Example
- "100100" -> 2. Zeros sit at indices 1, 2, 4, 5. The only cut must fall between index 2 and index 4, giving "100" | "100" and "1001" | "00".
- "0000" -> 1 — the single cut "00" | "00".
- Tricky cases: an odd number of zeros -> 0; a string with no zeros at all -> 0, since every piece needs two.
asked …