#K84587. Uniform String Operations
Uniform String Operations
Uniform String Operations
You are given several test cases. For each test case, an integer n and a string s with length n are provided. Your task is to determine the minimum number of operations required to make all characters in the string identical. In one operation, you can change any single character to any other character. The answer for each test case is the difference between n and the frequency of the most frequent character in the string.
The problem can be mathematically stated as: $$\text{operations} = n - \max_{c \in s}\{\text{count}(c)\}.$$
Read the input from standard input and print the output to standard output. Ensure your solution works for all given test cases.
inputFormat
The first line contains an integer T which denotes the number of test cases. Each of the following T lines contains a test case, and each test case has two inputs separated by space: an integer n (the length of string) and the string s itself.
outputFormat
For each test case, output a single integer denoting the minimum number of operations required to make all characters of the string identical. Each answer should be printed on a new line.
## sample2
5 aabcd
6 xyzzdz
3
3
</p>