Skip to content
Decoder

Valid Palindrome II

Easy

Problem

Given a string s, return true if it can become a palindrome after deleting at most one character. A palindrome reads the same forwards and backwards.

Example 1

Input
s = "aba"
Output
true
Why
already a palindrome

Example 2

Input
s = "abca"
Output
true
Why
delete "c" or "b"

Example 3

Input
s = "abc"
Output
false

Constraints

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

Read it once before you touch anything

Want some pressure? Start the timer. In an interview you get about two minutes to understand the problem.

  1. 1Read the goalWhat goes in, what comes out
  2. 2Scan the examplesCheck one by hand
  3. 3Note the constraintsThey set your Big O
Say what it asks in one sentence
Say it out loud first, then compare with ours.