#K93272. Minimum Moves to Palindrome
Minimum Moves to Palindrome
Minimum Moves to Palindrome
Given a string s and an integer k, determine the minimum number of moves required to convert s into a palindrome. A single move involves changing the position of a letter. For this problem, the minimum number of moves is equivalent to the number of mismatched character pairs when comparing the string with its reverse.
A palindrome is a string that reads the same forwards and backwards. Although each test case provides a parameter k indicating the maximum number of allowed moves, this parameter does not affect the outcome, as the solution is based solely on the count of mismatched pairs.
Your task is to process multiple test cases. For each test case, output the computed minimum number of moves on a new line.
inputFormat
The input starts with a single integer T (the number of test cases). Each of the following T lines contains a test case with a non-empty string s and an integer k separated by a space.
Example: abca 1
outputFormat
For each test case, print a single integer representing the minimum number of moves required to convert the given string into a palindrome. Each result should be output on a new line.
## sample3
abca 1
abcdefg 3
racecar 2
1
3
0
</p>