Check whether a string can become a palindrome after deleting at most one character.
Given a string s, determine whether it can be converted into a palindrome by removing at most one character.
A palindrome reads the same forward and backward. You may choose to delete zero characters as well, which means an already-palindromic string should return true.
Return true if the string can be made into a palindrome after at most one deletion, otherwise return false.
s.true if s can be a palindrome after deleting at most one character.false.s contains lowercase English letters.Example 1
Input
s = "aba"
Output
true
Explanation
The string is already a palindrome, so no deletion is needed.
Example 2
Input
s = "abca"
Output
true
Explanation
Deleting either b or c makes the string a palindrome ("aca" or "aba").
Example 3
Input
s = "abc"
Output
false
Explanation
No single deletion can turn it into a palindrome.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.