整体思路:先找到可能存在问题的点,然后判断,如果一切正常则左指针会来到字符串中部
bool isValidPalindrome(char *s, int i, int j)
{while (i < j) {if (s[i] != s[j]) {return false;}i++;j--;}return true;
}bool validPalindrome(char * s)
{int sz = strlen(s);int i = 0, j = sz - 1, half = sz / 2;while (i < half) {if (s[i] != s[j]) {break;}i++;j--;}return i == half || isValidPalindrome(s, i, j - 1) || isValidPalindrome(s, i + 1, j);
}