# Valid Palindrome II

## Problem

Given a non-empty string `s`, you may delete **at most** one character. Judge whether you can make it a palindrome.

{% hint style="info" %}
For example:

```
Input: "aba"
Output: True
```

```
Input: "abca"
Output: True
Explanation: You could delete the character 'c'.
```

{% endhint %}

### Thought Process

![](https://1063826111-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MGdx41c9p2PMgIHbUTK%2F-MNQLQgOsHzsq86Fket-%2F-MNQLiCPq2_Mvb-W38cy%2FIMG_95E00FA94B54-1.jpeg?alt=media\&token=f59c1dee-be5b-4fe4-b467-d9e2537b6f22)

## Solution

```
class Solution:
    def validPalindrome(self, s: str) -> bool:
        
        def isPalindrome(s,l,r):
            while l < r:
                if s[l] != s[r]:
                    return False
                l+=1
                r-=1
            return True
        
        l = 0
        r = len(s)-1
        
        while l < r:
            if s[l] != s[r]:
                return isPalindrome(s, l+1, r) or isPalindrome(s, l, r-1)
            l += 1
            r -= 1
        return True
```
