Valid Palindrome II

Given a string s, return true if s can be a palindrome after deleting at most one character from it.

Example 1
Inputs = "aba"
Outputtrue
The string is already a palindrome, so no deletion is needed.
Example 2
Inputs = "abca"
Outputtrue
You could delete the character 'c'.

Constraints

  • 1 <= s.length <= 10^5
  • s consists of lowercase English letters.

Asked at 16 companies

Practice questions like this out loud in a mock coding interview with a live AI interviewer. First one free.

Your Solution

(Ctrl/Cmd + Enter)

Switching Language

Loading template...

Sign in to save your progress

AI code evaluation

Get a correctness verdict, what to keep, what's wrong, and the complexity of your solution.

Sign in to evaluate