zeros, ones and max_run.
Count the strings made of 0 and 1 that:
- contain exactly zeros zeros;
- contain exactly ones ones;
- never have more than max_run equal characters in a row.
The count can be huge, so return it modulo 10⁹ + 7.zeros=2, ones=1, max_run=1 → 1
The two zeros cannot be adjacent, so only 010 works.
zeros=2, ones=2, max_run=1 → 2
The bits must alternate: 0101 and 1010.
zeros=3, ones=2, max_run=2 → 7
Of the 10 arrangements of three zeros and two ones, three fail: 00011, 10001 and 11000 each have three zeros in a row. That leaves 7.
zeros=2, ones=1, max_run=1
1
Run checks the first 3 tests in your browser. Submit checks all 69 tests on the server, hidden ones included.