#K88877. Valid Palindrome II
Valid Palindrome II
Valid Palindrome II
You are given a string s
. Your task is to determine whether s
is a palindrome or can become a palindrome after removing at most one character.
A palindrome is a string that reads the same backwards and forwards. The twist in this problem is that you may remove one character from s
(or no characters at all) to make it a palindrome. For example, the string "abca"
can be turned into a palindrome by removing the character "b"
or "c"
.
Note: An empty string or a single character is considered a palindrome.
The solution should read input from the standard input (stdin) and output the result to the standard output (stdout). Output True
if the string is a valid palindrome under the given conditions, otherwise False
.
inputFormat
The input consists of a single line containing a non-negative string s
. The string may be empty. Read the string from standard input.
outputFormat
Output a single line to the standard output: True
if the string is a palindrome or can be transformed into a palindrome by removing at most one character, or False
otherwise.
abca
True