#K3456. Valid Palindrome with One Removal

    ID: 25336 Type: Default 1000ms 256MiB

Valid Palindrome with One Removal

Valid Palindrome with One Removal

Given a string s consisting of lowercase alphabetic characters, determine if it is possible to make s a palindrome by removing at most one character. A palindrome is a string that reads the same forwards and backwards.

You are allowed to remove exactly zero or one character from s to achieve a palindrome.

Example:

  • Input: abca → Output: True because removing the character c results in aba, which is a palindrome.
  • Input: abcd → Output: False because it cannot be turned into a palindrome by removing just one character.

Your solution should consider all edge cases, such as strings of length 1.

The mathematical condition for a palindrome is given by:

$$ s[i] = s[n-i-1] \quad \text{for all } 0 \leq i < n $$

inputFormat

The input consists of a single line containing a non-empty string s of lowercase alphabetic characters.

outputFormat

Print True if the string can be transformed into a palindrome by removing at most one character; otherwise, print False.

## sample
abca
True