#C8449. Minimum Flips to Make a Binary String Alternating
Minimum Flips to Make a Binary String Alternating
Minimum Flips to Make a Binary String Alternating
Given a binary string s, determine the minimum number of flips required to transform it into an alternating binary string. An alternating binary string is one in which no two adjacent characters are the same. In other words, the string must follow either the pattern 0,1,0,1,... or 1,0,1,0,....
Mathematically, if we denote the two possible patterns by \(P_1\) and \(P_2\), we need to compute:
\[ \min\{\text{number of mismatches with } P_1,\, \text{number of mismatches with } P_2\}\]A flip is defined as changing a character from '0' to '1' or from '1' to '0'.
inputFormat
The input consists of a single line that contains a binary string s (a string composed only of the characters '0' and '1').
outputFormat
Output a single integer representing the minimum number of flips required to convert the given binary string into an alternating binary string.
## sample100101
2
</p>