Link:
Track: Amazon Tag

Question

Restate

Edge Case


Method 1
Method 2

Method

Approach

(discussed at lease two approach?)

Complexity

  • Time Complexity:
  • Space Complexity:

Code

class Solution:
    def validPalindrome(self, s: str) -> bool:
        left = 0
        right = len(s) - 1   
        def pali(left, right, skip_flag):
            while left < right:
                if s[left] == s[right]:
                    left += 1
                    right -= 1
                else:
                    if skip_flag:
                        return pali(left + 1, right, False) or pali(left, right - 1, False)
                    else:
                        return False
            
            return True
                
        return pali(left, right, True)

History

  • Feb-18-2026 - Peeked