#K58367. Minimum Character Changes to Palindrome

    ID: 30627 Type: Default 1000ms 256MiB

Minimum Character Changes to Palindrome

Minimum Character Changes to Palindrome

Given a string s, determine the minimum number of character changes required to transform it into a palindrome. A character change means modifying a character to any other character. A palindrome is a string that reads the same forwards and backwards. In this problem, you only need to compare symmetric pairs, so the number of required changes is given by:

$$\text{changes} = \sum_{i=0}^{\lfloor\frac{n}{2}\rfloor-1} [s[i] \neq s[n-i-1]]$$

where \(n\) is the length of the string and \([s[i] \neq s[n-i-1]]\) is 1 if the characters differ, otherwise 0.

inputFormat

The first line contains an integer T denoting the number of test cases. Each of the next T lines contains a single non-empty string s.

outputFormat

For each test case, output a single integer on a new line representing the minimum number of character changes required to convert the string into a palindrome.

## sample
4
ab
abcd
racecar
abcba
1

2 0 0

</p>