Palindrome string
680. Valid Palindrome II (Easy)
Input: "abca"
Output: True
Explanation: You could delete the character 'c'.
Subject description:
You can delete a character, it can be configured to determine whether the palindrome string.
Code:
public boolean validPalindrome(String s){
int i==-1;
int j=s.length();
while(++i<--j){
if(s.charAt(i)!=s.charAt(j)){
return isPalindrome (s, i, j-1) || isPalindrome (s, i + 1, j); // After deleting a character, it is determined whether the remaining palindrome
}
}
private boolean isPalindrome(String s ,int i,int j){
while(i<j){
if(s.charAt(i++)!=s.charAt(j--))
return false;
}
return true;
}
}