Make Palindrome

3.9

10 votes
Basics of String Manipulation, String Algorithms, Algorithms
Problem

There is a string that consists of lowercase english alphabets and we have to make the string a palindrome
For this, we have 2 types of operations
1. Re-arrange the string however you want (this operation is free)
2. Add a new character to the end of the string (this operation will cost 1Re)

Your task is to calculate the minimum amount of money to make the string a palindrome

Input Format:
The first line contains one integer T the number of test cases
The first line of every test case consists of N, the length of the string 
The second line of every test case contains string S


Output Format:
For every test case output one integer, the minimum amount of money required to make the string a palindrome

Constraints:

1T1001N105

Sample Input
1
4
aabb
Sample Output
0
Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

Here we can re-arrange the string as abba , we need no extra characters to make this a palindrome

Editor Image

?