problem
solution:
不理解判断函数中的节点的问题。。。
class Solution { public: bool validPalindrome(string s) { int left = 0, right = s.size()-1; while(left<right) { if(s[left]!=s[right]) { return isValid(s, left, right-1) || isValid(s, left+1, right);//err.. } left++; right--; } return true; } bool isValid(string s, int left, int right) { while(left<right) { if(s[left]!=s[right]) return false; left++; right--; } return true; } };
参考
1. Leetcode_easy_680. Valid Palindrome II;
2. Grandyang;
3. C++ Easy to Understand Clear Explaination;
完