All problems
Valid Palindrome with One Removal
Problem
Return True if s can become a palindrome after deleting at most one character, and False otherwise.
Walk with two pointers; on the first mismatch try skipping either the left or the right character and test the remainder. An empty or single-character string is already a palindrome.
Hint
Only the first mismatch matters because at most one deletion is allowed.
Test cases
case 1
in: ["aba"]
expected: true
case 2
in: ["abca"]
expected: true
case 3
in: ["abc"]
expected: false
case 4
in: [""]
expected: true
case 5
in: ["a"]
expected: true
case 6
in: ["abccba"]
expected: true
Starter codePython
def valid_palindrome_one_removal(s):
# Your code here
pass6 test cases · run your code against them in the editor