#C6650. Valid Palindrome with One Removal

    ID: 50434 Type: Default 1000ms 256MiB

Valid Palindrome with One Removal

Valid Palindrome with One Removal

Given a string \(S\), determine if it is possible to transform \(S\) into a palindrome by removing at most one character. A palindrome is a string that reads the same forwards and backwards. Your task is to check each string and print Yes if the string can be a palindrome with at most one removal, and No otherwise.

Examples:

  • For \(S = \texttt{abca}\), you can remove either \(b\) or \(c\) to get \(\texttt{aca}\), which is a palindrome.
  • For \(S = \texttt{racecar}\), the string is already a palindrome.
  • For \(S = \texttt{abcdef}\), it cannot be made a palindrome by removing just one character.

inputFormat

The input starts with an integer \(T\) representing the number of test cases. Each of the following \(T\) lines contains a non-empty string \(S\).

outputFormat

For each test case, output Yes if the string can become a palindrome by removing at most one character; otherwise, output No. Each result should be printed on a new line.

## sample
3
abca
racecar
abcdef
Yes

Yes No

</p>