Make a Binary String Alternate
s is a binary string. In one operation you flip a single character (0 to 1 or 1 to 0). A string alternates if no two neighbouring characters are equal, like 0101 or 1010. Return the fewest flips that make s alternate.
Example 1
s "0100"
returns 1
Flip the last character to get 0101.
Example 2
s "1111"
returns 2
Two flips give 1010.
Constraints
1 <= len(s) <= 50
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.