#C4819. One Change Palindrome
One Change Palindrome
One Change Palindrome
You are given a string S. Your task is to determine whether S can be transformed into a palindrome by modifying at most one character. In other words, check if you can change at most one character in S so that the resulting string is a palindrome.
A string is a palindrome if it reads the same backward as forward. Formally, a string S of length n is a palindrome if for every i, \(S[i] = S[n-i-1]\). You are allowed up to one mismatch correction.
Note: If the input string is already a palindrome, it is considered valid since no changes or one change (i.e., doing nothing) is within the limit.
Input Constraints: The input string can be of any length from 1 to large values. Efficiency for long strings is required.
Example:
Input: ABABA Output: YES</p>Input: AAABB Output: NO
Hint: Count the number of positions i (from 0 to \(\lfloor\frac{n}{2}\rfloor - 1\)) where \(S[i] \neq S[n-i-1]\). If the count is more than 1, then it is not possible to transform the string into a palindrome using at most one change.
inputFormat
The input consists of a single line containing the string S.
Format:
S
outputFormat
Output a single line containing either "YES" or "NO". Output "YES" if the string S can be transformed into a palindrome with at most one change; otherwise, output "NO".
## sampleA
YES
</p>