#K91852. Almost Palindrome
Almost Palindrome
Almost Palindrome
Given a string s
, determine whether it is an almost palindrome. A string is considered almost palindrome if it is not a palindrome itself, but by removing exactly one character, it can become a palindrome.
For example, if s = "abca"
, by removing the character 'b'
or 'c'
the string becomes "aca" or "aba", both of which are palindromes. On the other hand, if s
is already a palindrome (e.g., "racecar") or cannot be transformed into a palindrome by a single removal, then it is not an almost palindrome.
Note: A palindrome is a string that reads the same backward as forward. Mathematically, a string s
of length n is a palindrome if
\( s_i = s_{n-i+1} \) for all \( 1 \leq i \leq n \).
inputFormat
The input consists of a single line containing a non-empty string s
. The string s
contains only printable characters.
outputFormat
Output either True
if the string is almost a palindrome, or False
otherwise.
radkar
True