Search
⌘K

Leetcode 1513. Number of Substrings With Only 1s

Count how many substrings of a binary string consist entirely of '1's (return the result modulo 1e9+7). The core challenge is to compute, in linear time, the sum of L*(L+1)/2 over each contiguous run of L ones to handle strings up to 1e5 length and large counts.


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.