# 680\_Valid Palindrome II

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

**Example 1:**

```
Input:
 "aba"

Output:
 True
```

**Example 2:**

```
Input:
 "abca"

Output:
 True

Explanation:
 You could delete the character 'c'.
```

**Note:**

1. The string will only contain lowercase characters a-z. The maximum length of the string is 50000.

## Solution

```python
class Solution(object):
    def validPalindrome(self, s):
        """
        :type s: str
        :rtype: bool
        """
        left, right = 0, len(s) - 1
        while left < right:
            if s[left] == s[right]:
                left += 1
                right -= 1
            else:
                temp1 = s[left : right]  # if delete right element
                temp2 = s[left+1 : right + 1] # if delete left element
                return temp1 == temp1[::-1] or temp2 == temp2[::-1]
        return True
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://lei-d.gitbook.io/leetcode/string/680valid-palindrome-ii.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
