#K61807. Palindrome Transformation
Palindrome Transformation
Palindrome Transformation
You are given a string s
consisting only of lowercase English letters. Your task is to determine whether it is possible to transform s
into a palindrome by removing at most one character.
A palindrome is a string which reads the same forwards and backwards. Formally, a string \(s\) is a palindrome if \(s = s^R\), where \(s^R\) is the reverse of s
.
If the input string is already a palindrome, then no removal is needed. Otherwise, check if there exists an index such that by removing the character at that index, the resulting string becomes a palindrome.
Output YES
if it is possible to obtain a palindrome by removing at most one character; otherwise, output NO
.
inputFormat
The input consists of a single line containing the string s
(1 \(\leq\) |s| \(\leq\) 105), where |s| denotes the length of s
.
outputFormat
Output a single line: YES
if the string can be transformed into a palindrome by removing at most one character, or NO
otherwise.
abcba
YES
</p>