Company: Carousell Pte Ltd Back-End Developer Hiring Test Set 4_16may
Difficulty: medium
You are given a binary string password consisting only of characters '0' and '1'. To be considered secure, the password must be split into non-overlapping substrings such that: Each substring has an even length Each substring contains only one type of character (all '0's or all '1's) Your task is to determine the minimum number of character flips required to make this division possible. Note: A flip changes a '0' to '1' or a '1' to '0'. Example Suppose password = "1110011000" Output: 3 Explanation: One optimal solution is to flip the zeros at positions 3, 4, and 7 to get "1111111100". This can be divided into two valid substrings: "11111111" and "00". Both substrings have even length and contain only one type of character. Constraints 2 ≤ length of password ≤ 10 5 The length of password is even. password contains only 1s and 0s.