#C10162. Minimum Moves to Make a Palindrome
Minimum Moves to Make a Palindrome
Minimum Moves to Make a Palindrome
You are given a string \( S \) and your task is to determine the minimum number of moves required to convert \( S \) into a palindrome. In one move, you can correct a mismatched pair of characters. More formally, for a string of length \( n \), consider the characters at positions \( i \) and \( n-i+1 \) for \( 1 \leq i \leq \lfloor n/2 \rfloor \). For every pair where these characters differ, you need one move.
Each test case provides an integer \( N \) (the length of the string) and the string \( S \) itself. Use the information to verify that the string is of the expected length if necessary.
inputFormat
The first line of the input contains an integer \( T \), representing the number of test cases. Each of the following \( T \) lines contains a test case with an integer \( N \) (the length of the string) and the string \( S \) separated by a space.
\( 1 \leq T \leq 10^5 \)
outputFormat
For each test case, output a single line containing the minimum number of moves required to convert the given string into a palindrome.
## sample3
3 abc
4 abba
5 abcba
1
0
0
</p>