#C10620. Minimum Operations to Palindrome

    ID: 39846 Type: Default 1000ms 256MiB

Minimum Operations to Palindrome

Minimum Operations to Palindrome

Given a string \( s \), determine the minimum number of operations required to transform it into a palindrome. In one operation, you can fix a mismatched pair of characters. Formally, for a string of length \( n \), for each index \( i \) (where \( 0 \le i < \lfloor \frac{n}{2} \rfloor \)), if \( s[i] \neq s[n-i-1] \), then one operation is needed. Your task is to compute the total number of such mismatched pairs.

inputFormat

The first line contains an integer ( T ) denoting the number of test cases. Each of the following ( T ) lines contains a non-empty string.

outputFormat

For each test case, output a single integer representing the minimum number of operations required to transform the string into a palindrome. Each result should be printed on a new line.## sample

4
ab
aa
racecar
aabb
1

0 0 2

</p>