#C10590. Minimum Operations to Uniform String
Minimum Operations to Uniform String
Minimum Operations to Uniform String
You are given several strings. For each string, the task is to determine the minimum number of operations required to make all the characters in the string identical. In one operation, you can change a character to any other character.
The minimum operations for a string s is given by:
$$operations = |s| - \max_{c \in s}\{ \text{count}(c) \} $$where \(|s|\) is the length of the string and \(\text{count}(c)\) is the frequency of character \(c\) in s.
You need to process multiple test cases.
inputFormat
The input is read from stdin and has the following format:
T s1 s2 ... sT
Where:
T
is an integer representing the number of test cases.- Each of the following
T
lines contains a non-empty strings
consisting of lowercase letters.
outputFormat
For each test case, output the minimum number of operations required to convert the string into a string with all characters the same. Each result should be printed on a separate line to stdout.
## sample3
aabb
abcde
zzzzz
2
4
0
</p>