~/DHRUVUpskilling
← board/DSA/Two Pointers/DSA-15
Backlog·queued

Valid Palindrome II

DifficultyMedium
PatternTwo Pointers
TrackDSA
tl;dr

Write a function that takes a string as input and checks whether it can be a valid palindrome by removing at most one character from it.

full write-up

Constraints

  • 1 ≤ string.length ≤ 10³
  • The string only consists of English letters.

Examples

Example 1

Input: "ABCEBA" Output: TRUE

Example 2

Input: "RACEACAT" Output: FALSE

Example 3

Input: "DEEAD" Output: TRUE