<p>Given a string <code>s</code>, return <code>true</code> <em>if the </em><code>s</code><em> can be palindrome after deleting <strong>at most one</strong> character from it</em>.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<pre>
<strong>Input:</strong> s = &quot;aba&quot;
<strong>Output:</strong> true
</pre>

<p><strong class="example">Example 2:</strong></p>

<pre>
<strong>Input:</strong> s = &quot;abca&quot;
<strong>Output:</strong> true
<strong>Explanation:</strong> You could delete the character &#39;c&#39;.
</pre>

<p><strong class="example">Example 3:</strong></p>

<pre>
<strong>Input:</strong> s = &quot;abc&quot;
<strong>Output:</strong> false
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>1 &lt;= s.length &lt;= 10<sup>5</sup></code></li>
	<li><code>s</code> consists of lowercase English letters.</li>
</ul>

class Solution {
    pair<int, int> isPalindrome(string s, int start, int end) {
        while (end > start) {
            if (s[start] != s[end]) {
                return {start, end};
            }

            end -= 1;
            start += 1;
        }

        return {-1, -1};
    }
public:
    bool validPalindrome(string s) {
        pair<int, int> result = isPalindrome(s, 0, s.length()-1);
        if (result.first == -1) return true;

        pair<int, int> delete_left = isPalindrome(s, result.first+1, result.second);
        if (delete_left.first == -1) return true;
        pair<int, int> delete_right = isPalindrome(s, result.first, result.second-1);
        if (delete_right.first == -1) return true;

        return false;
    }
};
28979