Description
Given a string s consisting only of 0s and 1s, return the minimum number of operations to make s alternating.
Examples
Input:
s = "0100"Output:
1Explanation:
Change to 0101.
Input:
s = "a"Output:
0Explanation:
A single-character string is already alternating, so 0 changes are needed.
Input:
s = "10110"Output:
2Explanation:
Changing to "10101" requires 2 changes (positions 2 and 3), while changing to "01010" requires 3 changes (positions 0, 2, and 4). The minimum is 2.
Constraints
- •
1 ≤ s.length ≤ 10^4