Count binary substrings

0
Remix

Count the non-empty substrings of a binary string that have the same number of 0s and 1s, with all the 0s together and all the 1s together. Solve it in one pass by comparing lengths of consecutive runs.

MicrosoftOnline assessmentLast asked Aug 2026
No answer yet. Write the first one; the best answer gets endorsed.