Count Binary Substrings
Easy · Arrays & Strings · about 15 minutes
Asked at Bloomberg, Amazon, Microsoft, Google, Salesforce.
s is made of 0s and 1s. Count its substrings that consist of a block of one digit followed directly by an equally long block of the other digit, such as "0011" or "10". Occurrences at different positions are counted separately, even if the text is the same.