I scan the string once and accumulate lengths of consecutive '1' runs. For each run of length L the number of substrings containing only '1' inside that run is L*(L+1)//2. I sum those values while taking modulo 10**9 + 7 to avoid overflow, and return the result.
- Time: O(n)
- Space: O(1)