Company: IBM
Difficulty: medium
Problem Title: Valid Substrings in Binary String A binary string S (containing only 0s and 1s) encodes an encryption key represented by the count of valid substrings in S . A substring is valid if it meets the following conditions: No two adjacent characters are the same. Its length is between minLength and maxLength , inclusive. Return the number of valid substrings, which represents the encryption key for S . Input Format The input consists of: A binary string S . An integer minLength . An integer maxLength . Output Format Return a single integer representing the count of valid substrings. Constraints 1 ≤ |S| ≤ 10 5 (length of the string) 1 ≤ minLength ≤ maxLength ≤ |S| Examples Input: S = \"1011\" minLength = 2 maxLength = 3 Output: 5 Valid substrings are: \"10\", \"01\", \"11\", \"10\", \"101\".