#C4543. Almost Palindrome (Change One Character)

    ID: 48093 Type: Default 1000ms 256MiB

Almost Palindrome (Change One Character)

Almost Palindrome (Change One Character)

Given a string \(T\) of length \(M\) consisting solely of lowercase English letters, determine whether \(T\) can be transformed into a palindrome by changing exactly one character. A string is considered an almost palindrome if by modifying exactly one character, it becomes a palindrome.

Note that for an odd-length string that is already a palindrome, changing its middle character to any other letter is allowed and still qualifies as an almost palindrome.

For example, the string "abcca" can be converted to a palindrome by changing the second character 'b' to 'c', resulting in "accca".

inputFormat

The input consists of two lines:

  • The first line contains an integer \(M\), denoting the length of the string \(T\).
  • The second line contains the string \(T\) consisting only of lowercase English letters.

outputFormat

Output a single line containing YES if the string \(T\) can be converted into a palindrome by changing exactly one character, otherwise output NO.

## sample
5
abcca
YES