#K51202. Non-Palindromic Transformation Operations

    ID: 29035 Type: Default 1000ms 256MiB

Non-Palindromic Transformation Operations

Non-Palindromic Transformation Operations

Given a string, determine the minimum number of operations required to transform it into a non-palindromic string. An operation is defined as changing a single character. If the string is already non-palindromic, no operations are needed. Note that for a single-character string, it is impossible to make it non-palindromic by rearrangement, so we consider one operation necessary.

In formal terms, for a string \( s \) of length \( n \), if \( s \) is palindromic (i.e. \( s = s^R \)), then the answer is \( 1 \); otherwise, it is \( 0 \). It is guaranteed that \( s \) consists of lowercase English letters only.

inputFormat

The input begins with an integer ( T ) denoting the number of test cases. Each test case consists of a single line containing an integer ( n ) and a string ( s ) (of length ( n )) separated by a space.

outputFormat

For each test case, output a single integer representing the minimum number of operations required, each on a new line.## sample

1
1 a
1

</p>