Determine the minimum number of character changes needed to make a binary string satisfy the problem's definition of “beautiful.”
You are given a binary string s. You may change any character ('0' to '1' or '1' to '0') in one move.
Your task is to find the minimum number of moves required to make the string beautiful.
For this problem, a binary string is considered beautiful when it can be transformed into a valid target form by changing the fewest possible characters.
Return the minimum number of changes needed.
'0' and '1'.s.1 <= |s|s consists only of characters '0' and '1'.Example 1
Input
s = "0011"
Output
0
Explanation
The string already satisfies the target form, so no changes are needed.
Example 2
Input
s = "0101"
Output
2
Explanation
Two positions must be flipped to match a valid beautiful form.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.