#C1431. Minimum Flips to Make Binary String Alternating
Minimum Flips to Make Binary String Alternating
Minimum Flips to Make Binary String Alternating
You are given a binary string s consisting only of characters '0' and '1'. Your task is to determine the minimum number of flips required so that the string becomes alternating. A string is considered alternating if no two adjacent characters are the same. In other words, for a string s of length n, it must follow:
\(s_i \neq s_{i+1}\) for all \(1 \leq i < n\).
Consider the two possible alternating strings of length n:
- \(a = 010101\ldots\)
- \(b = 101010\ldots\)
Your goal is to calculate the minimum flips required to change the given string into either of these alternating patterns.
inputFormat
The input consists of a single binary string s provided via standard input.
Constraints: 1 \leq length(s) \leq 10^5.
outputFormat
Output a single integer on standard output --- the minimum number of flips required to transform the input string into an alternating string.
## sample001
1
</p>