标签:删掉 str solution als false -- pre 字符 ret
class Solution {
public:
bool validPalindrome(string s) {
int len = s.size();
if(len<=2){
return true;
}
return judge(s, 0, len-1, 1);
}
private:
bool judge(string s, int left, int right, int diff){
while(left < right){
if(s[left] != s[right]){
if(diff == 0 ){
return false;
}
return judge(s, left+1, right, diff-1) || judge(s, left, right-1, diff-1);
}
left++;
right--;
}
return true;
}
};
leetcode680 C++ 124ms 删掉一个字符后能否构成回文
标签:删掉 str solution als false -- pre 字符 ret
原文地址:https://www.cnblogs.com/theodoric008/p/9377105.html