📘
Valid Palindrome II
Given a string s, return True if s can be a palindrome after deleting at most one character.
Example:
Input:
aba
Output:
True
Reasoning:
- The input string
sis "aba", which is already a palindrome since it reads the same backward as forward. - No character needs to be deleted to make it a palindrome.
- The condition of deleting at most one character is satisfied, as no deletion is required.
- The function returns
True, indicating that the string can be a palindrome after deleting at most one character.
Constraints:
- 1 <= len(s) <= 10^5
- s consists of lowercase English letters
Editor
Python 3.13.1
Test Results
0/0Run code to see test results.