#C6546. Modified Palindromes

    ID: 50318 Type: Default 1000ms 256MiB

Modified Palindromes

Modified Palindromes

You are given a positive integer \(T\) and \(T\) strings. For each string, determine if it is a modified palindrome. A string is called a modified palindrome if either:

  • It is already a palindrome, or
  • It can become a palindrome by removing exactly one character.

A palindrome is a string that reads the same forwards and backwards. Formally, a string \(s\) of length \(n\) is a palindrome if \(s_i = s_{n-i+1}\) for all \(1 \leq i \leq n\).

Your task is to determine for each input string whether it is a modified palindrome.

inputFormat

The first line contains an integer \(T\) (the number of test cases). Each of the next \(T\) lines contains a string consisting of lowercase letters.

\(1 \leq T \leq 10^5\). Each string's length is at least 1 and can be large.

outputFormat

For each test case, output a single line containing YES if the corresponding string is a modified palindrome; otherwise, output NO.

## sample
3
abca
racecar
hello
YES

YES NO

</p>