#K91447. Minimum Changes to Palindrome
Minimum Changes to Palindrome
Minimum Changes to Palindrome
Given a non-negative integer, your task is to determine the minimum number of digit changes required to transform it into a palindrome. A palindrome is a number that reads the same forwards and backwards. For each number, you can change any digit to any other digit.
Formally, let the number be represented as a string \( s \) of length \( n \). For every index \( i \) where \( 0 \leq i < \lfloor n/2 \rfloor \), if \( s[i] \neq s[n-1-i] \), a change is required. The answer is the count of such mismatched pairs.
You will be given \( T \) queries. For each query, compute the minimum changes required to convert the number into a palindrome.
inputFormat
The first line of input contains a single integer \( T \) representing the number of queries.
The following \( T \) lines each contain a non-negative integer. Each integer is given without leading zeros and can be very large, so it is advised to process it as a string.
outputFormat
For each query, output the minimum number of digit changes required to transform the given number into a palindrome. Each result should be printed on a new line.
## sample4
12321
12
39
12345
0
1
1
2
</p>