125. Valid Palindrome
1 public class Solution { 2 public boolean isPalindrome(String s) { 3 char[] str = s.toCharArray(); 4 if(str.length == 0) 5 return true; 6 for(int i = 0,j = str.length-1; i <=j; ){ 7 if(!vaidIput(str[i])){ 8 ++i; 9 continue; 10 } 11 if(!vaidIput(str[j])){ 12 --j; 13 continue; 14 } 15 16 if(Character.toUpperCase(str[i]) == Character.toUpperCase(str[j])){ 17 ++i; 18 --j; 19 }else{ 20 return false; 21 } 22 } 23 return true; 24 } 25 26 static boolean vaidIput(char a) 27 { 28 return ((a>='a'&&a<='z')||(a>='A'&&a<='Z')||(a>='0'&&a<='9')); 29 } 30 }