#K65837. Minimum Operations to Palindrome
Minimum Operations to Palindrome
Minimum Operations to Palindrome
You are given a string s of length n. Your task is to determine the minimum number of operations required to transform the string into a palindrome. An operation consists of selecting a pair of characters s[i] and s[n-1-i] (for 0 \le i < n/2) that are different and changing one of them so that they become equal.
This can be mathematically expressed as:
$$ \text{operations} = \sum_{i=0}^{\lfloor n/2 \rfloor - 1} \mathbf{1}_{\{s[i] \neq s[n-1-i]\}} $$
Compute and output the minimum number of operations needed.
inputFormat
The input consists of two lines:
- The first line contains an integer n — the length of the string.
- The second line contains a string s of length n composed of lowercase letters.
outputFormat
Output a single integer — the minimum number of operations required to transform s into a palindrome.
## sample4
abca
1
</p>