题目描述
思路
代码
class Solution {
public:
bool palindrome(string& s, int i, int j)
{
for ( ; i < j && s[i] == s[j]; ++i, --j);
return i >= j;
}
bool validPalindrome(string s) {
int i = 0, j = s.size() - 1;
for ( ; i < j && s[i] == s[j]; ++i, --j);
return palindrome(s, i, j - 1) || palindrome(s, i + 1, j);
}
};
标签:palindrome,return,--,680,int,bool,Leetcode
From: https://www.cnblogs.com/ALaterStart/p/16743788.html