#C2477. Minimum Operations to Maximize Uniform Subsegment
Minimum Operations to Maximize Uniform Subsegment
Minimum Operations to Maximize Uniform Subsegment
Problem Statement:
Given a binary string s, determine the minimum number of operations required to convert s into a uniform string (i.e. all characters are identical) by flipping individual characters. In a single operation, you can change a '0' to a '1' or a '1' to a '0'.
To achieve a uniform string with the maximum possible subsegment length (which is the entire string), it is optimal to flip the characters that are in the minority. This can be expressed mathematically as:
$$ \min(#0,; #1) $$
where (#0) and (#1) denote the number of '0's and '1's in s, respectively.
inputFormat
A single line containing the binary string s.
outputFormat
Print an integer representing the minimum number of operations required to make the string uniform.## sample
0
0
</p>