bits made of the characters 0 and 1, and a number width.
In one move you may pick any contiguous stretch of the string of length exactly width and invert it: every 0 in it becomes 1 and every 1 becomes 0. You may make any number of moves, including none.
How many different strings can you end up with? The original string counts too. The answer can be large, so return it modulo 10⁹ + 7.bits='0110', width=2 → 8
There are three windows of length 2 (starting at 0, 1 and 2), and every subset of them yields its own string: 2³ = 8 variants, the original included.
bits='101', width=3 → 2
There is a single window, the whole string, giving "101" and "010".
bits='1', width=1 → 2
width ≤ bits.length ≤ 10⁵bits consists only of the characters 0 and 1bits='0110', width=2
8
Run checks the first 3 tests in your browser. Submit checks all 114 tests on the server, hidden ones included.