Search
⌘K

Leetcode 696. Count Binary Substrings

Count the non-empty substrings of a binary string that contain an equal number of 0s and 1s with all 0s and all 1s each grouped consecutively. Key insight: this reduces to comparing lengths of adjacent runs of identical bits and summing the minimums of each neighboring pair.


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.