TTN | OA Coding and Solutions
Question · Posted Apr 2026
Problem: Count Binary Substrings Objective: Given a binary string (a string consisting only of '0's and '1's), find the total number of substrings that satisfy two conditions: The substring contains an equal number of '0's and '1's. All '0's and '1's in that substring are grouped together (consecutively). Example Walkthrough: Input: s = "011001" Valid Substrings: "01" (index 0-1) "10" (index 2-3) "1100" (index 1-4) "01" (index 4-5) Invalid Substring Example: "0110" has equal '0's and '1's but is not ...
The full answer & interview discussion are available to premium members.
Log in Create a free account