#K68627. Transformable Palindrome (Taco Problem)
Transformable Palindrome (Taco Problem)
Transformable Palindrome (Taco Problem)
Given a string S, determine if it is possible to form a palindrome by removing at most one character from S.
A palindrome is a string that reads the same backwards as forwards. Your task is to check whether the given string can be transformed into a palindrome by deleting at most one character.
For example, for the string abca
, by removing the character b
or c
you can obtain aca
, which is a palindrome. If the string is already a palindrome, it should be considered valid.
In mathematical terms, given a string \( S \) of length \( n \), determine whether there exists an index \( i \) (with \( 0 \leq i < n \)) such that the string formed by removing the character \( S_i \) is a palindrome, or the string is already a palindrome.
inputFormat
The input consists of a single string S provided on one line from standard input.
outputFormat
Output YES
if the string can become a palindrome by removing at most one character, otherwise output NO
.
abca
YES
</p>