ntree.ai
ntree.aiValid Palindrome

Valid Palindrome

easysolvedattempted

Given a string s, return true if it can become a palindrome after removing at most one character.

A palindrome is a string that reads the same forwards and backwards.

Example 1:

Input:  s = "abcbad"
Output: true
Explanation: Removing `d` leaves `abcba`.

Example 2:

Input:  s = "abcda"
Output: false

Constraints:

  • 1 <= length of s <= 10^5
  • s consists of lowercase English letters
def validPalindrome(s: str) -> bool:
pass
 

Press Visualise to step through your code.