bits. Count its non-empty contiguous pieces (substrings) made only of the character 1. Equal pieces at different positions are counted separately.
The answer can be large, so return it modulo 10⁹ + 7.bits='11011' → 6
Each of the two "11" blocks holds three such pieces: "1", "1" and "11". 6 in total.
bits='000' → 0
There are no ones, so the answer is 0.
bits='0111' → 6
From "111": three pieces of length 1, two of length 2 and one of length 3, so 6.
bits contains only 0 and 1bits='11011'
6
Run checks the first 3 tests in your browser. Submit checks all 31 tests on the server, hidden ones included.