很簡單派诬,加入HashSet來進(jìn)行判斷
'''
class?Solution?{
????public?boolean?validPalindrome(String?s)?{
????????int?start=0;
????????int?end=s.length()-1;
????????while(start<end){
????????????if(s.charAt(start)==s.charAt(end)){
????????????????start++;
????????????????end--;
????????????}else{
????????????????return?panduan(start,end-1,s)||panduan(start+1,end,s);
????????????}
????????}
????????return?true;
????}
????public?boolean?panduan(int?left,int?right,String?s){
????????while(left<right){
????????????if(s.charAt(left)==s.charAt(right)){
????????????????left++;
????????????????right--;
????????????}else{
????????????????return?false;
????????????}
????????}
????????return?true;
????}
}
'''