bits of zeros and ones. Cut it into non-empty contiguous pieces so that every piece contains **exactly one** 1.
Return the number of ways to do it. If the array has no 1s, the answer is 0. The answer can be large, so return it modulo 10⁹ + 7.bits=[1, 0, 0, 1, 0, 1] → 6
Between the first and second 1 the cut can go in 3 places, between the second and third in 2. That gives 3 · 2 = 6 ways.
bits=[0, 0, 1, 0] → 1
There is a single 1, so the only option is the whole array as one piece: 1 way.
bits=[0, 0, 0] → 0
bits=[1, 0, 0, 1, 0, 1]
6
Run checks the first 3 tests in your browser. Submit checks all 90 tests on the server, hidden ones included.