#C2207. Minimum Operations to Convert a String into a Palindrome
Minimum Operations to Convert a String into a Palindrome
Minimum Operations to Convert a String into a Palindrome
You are given a string s
. In one operation, you can choose any single character in the string and change it to any other character. Determine the minimum number of operations required to convert the given string into a palindrome.
A string is a palindrome if it reads the same forward and backward. For example, "racecar" is a palindrome while "ab" is not.
Note: Only modifications are allowed; you cannot rearrange the letters.
inputFormat
The input is read from standard input (stdin
) and is structured as follows:
- An integer
t
that denotes the number of test cases. - Followed by
t
lines, each containing a single strings
.
outputFormat
For each test case, output the minimum number of operations required to convert the given string into a palindrome on a new line to standard output (stdout
).
3
a
ab
racecar
0
1
0
</p>