Loading...
Loading...
Loading...
A word can be fixed if removing at most one letter makes it read the same forwards and backwards. Print YES if the word can be fixed (or is already a palindrome), otherwise NO.
Example 1
Input
abca
Output
YES
Example 2
Input
abc
Output
NO
Try the problem first. Open one hint at a time.
Use two pointers until the first mismatch.
On a mismatch, check whether the rest is a palindrome after skipping the left letter or after skipping the right letter.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor