Count Substrings

Problem Overview

  • Given a binary string, count substrings where 0s and 1s are equal and appear as one block of 0s then 1s or 1s then 0s (e.g., "01", "10", "0011").
  • Input: string s of '0' and '1'; Output: integer count of such substrings; overlapping repetitions are counted.
  • Domain: string processing and binary pattern detection.
  • Asked in Salesforce interviews; a common coding interview problem and interview question.

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Input Variables
Execution Result: