Algorithm · Salesforce · Medium
Given a binary string s (containing only '0' and '1'), you need to count the number of non-empty substrings that meet both of the following criteria: The substring has an equal amount of '0's and '1's. Within the substring, all '0's are grouped into a single contiguous block and all '1's are grouped into a single contiguous block. Consequently, the substring must look like $$k$$ '0's followed by $$k$$ '1's, or $$k$$ '1's followed by $$k$$ '0's, for some positive integer…
Checking your access…