#K94937. Almost Palindromic String
Almost Palindromic String
Almost Palindromic String
Given a string s, determine whether it is almost palindromic. A string is almost palindromic if it can be transformed into a palindrome by modifying at most one character. In other words, when comparing the characters from both ends towards the center, if there is at most one mismatch, then the string is considered almost palindromic.
For example, the string "racecar" is already a palindrome, so it is almost palindromic. The string "abca" can be turned into a palindrome by changing one character, and thus it is almost palindromic, while the string "abcdef" requires more than one change and is not.
Your task is to determine and output YES if the input string is almost palindromic, otherwise output NO.
inputFormat
The input consists of a single line containing a non-empty string s
composed of lowercase English letters.
outputFormat
Output a single line: YES
if the string is almost palindromic, or NO
otherwise.
racecar
YES