#K82937. Valid Palindrome II

    ID: 36086 Type: Default 1000ms 256MiB

Valid Palindrome II

Valid Palindrome II

Given a string \(s\) consisting of lowercase alphabets, determine if it is a palindrome or if it can become a palindrome by removing at most one character.

A palindrome is a string that reads the same forward and backward. In other words, check if \(s\) is a palindrome or if there exists an index \(i\) such that removing the character \(s_i\) makes \(s\) a palindrome.

Examples:

  • Input: "abca"; Removing 'c' yields "aba" → Output: True
  • Input: "racecar"; Already a palindrome → Output: True
  • Input: "abcde"; Cannot be made palindrome with one removal → Output: False

Edge Cases: An empty string or a single character is considered a palindrome.

inputFormat

Input is read from standard input (stdin) as a single line string (s) that consists only of lowercase alphabets. There is no additional input.

outputFormat

Output a single line to standard output (stdout) containing either "True" or "False". "True" indicates that the string is a palindrome or can be made into one by removing at most one character; "False" otherwise.## sample

abca
True