Some error occured while loading page for you. Please try again.
James found a love letter that his friend Harry has written to his girlfriend. James is a prankster, so he decides to meddle with the letter. He changes all the words in the letter into palindromes.
To do this, he follows two rules:
Each reduction in the value of any letter is counted as a single operation. Find the minimum number of operations required to convert a given string into a palindrome.
For example, given the string , the following two operations are performed: cde → cdd → cdc.
Complete the theLoveLetterMystery function in the editor below. It should return the integer representing the minimum number of operations needed to make the string a palindrome.
theLoveLetterMystery has the following parameter(s):
The first line contains an integer , the number of queries.
The next lines will each contain a string .
| s |
All strings are composed of lower case English letters, *ascii[a-z], with no spaces.
A single line containing the minimum number of operations corresponding to each test case.