每日一题ing,今天是个easy题680. Valid Palindrome II
class Solution {
public:
static bool checkPalindrome(string s,int low,int high){
for(int i=low,j=high;i<j;i++,j--){
if(s[i]!=s[j]){
return false;
}
}
return true;
}
bool validPalindrome(string s) {
int i=0,j=s.size()-1;
while(i<j){
if(s[i]!=s[j]){
return checkPalindrome(s,i,j-1)||checkPalindrome(s,i+1,j);
}
else{
i++;j--;
}
}
return true;
}
};