Company: IBM
Difficulty: medium
Question 1: Count Valid Substrings 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 A string S , containing only binary characters (0s and 1s). Two integers minLength and maxLength , representing the minimum and maximum length for a valid substring. Output Format Return a single integer, the count of valid substrings in S . Constraints 1 ≤ |S| ≤ 2 × 10 5 1 ≤ minLength ≤ maxLength ≤ |S| Examples Input: S = \"1011\", minLength = 2, maxLength = 3 Output: 3 Substring Length Is valid? \"1\" 1 No (Length < minLength) \"0\" 1 No (Length < minLength) \"10\" 2 Yes \"01\" 2 Yes \"11\" 2 No (Adjacent repeating) \"101\" 3 Yes \"011\" 3 No (Adjacent repe