Math
1513. Number of Substrings With Only 1s
Count substrings consisting only of '1's, mod 1e9+7. A run of len consecutive 1s contains len·(len+1)/2 all-ones substrings (a triangular number); zeros split the string into independent runs whose…
Loading…