We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
给定一个非空字符串 s,最多 删除一个字符。判断是否能成为回文字符串。
s
Input: "aba" Output: True
Input: "abca" Output: True Explanation: You could delete the character 'c'.
The text was updated successfully, but these errors were encountered:
/** * @param {string} s * @return {boolean} */ var validPalindrome = function(s) { let chance = 1; return isPalindrome(s); function isPalindrome(s) { let left = 0; let right = s.length - 1; while (left < right) { if (s[left] !== s[right]) { if (chance > 0) { chance--; return isPalindrome(s.slice(0, left) + s.slice(left + 1)) || isPalindrome(s.slice(0, right) + s.slice(right + 1)); } else { return false; } } left++; right--; } return true; } };
Sorry, something went wrong.
No branches or pull requests
680. Valid Palindrome II
给定一个非空字符串
s
,最多 删除一个字符。判断是否能成为回文字符串。Example 1
Example 2
Note
The text was updated successfully, but these errors were encountered: