4.14
public class Solution {
/**
* @param s A string
* @return Whether the string is a valid palindrome
*/
public static boolean isPalindrome(String s) {
if(s == null){
return true;// Write your code here
}
s = s.toUpperCase();
int height = s.length()-1;
int low = 0;
while(low < height){
while(low < height && !isRight(s.charAt(low))){
low++;
}
while(low < height && !isRight(s.charAt(height))){
height--;
}
if(s.charAt(low) != s.charAt(height)){
return false;
}
else{
low ++;
height --;
}
}
return true;
}
public static boolean isRight(char s){
if(s>=65 && s<=90){
return true;
}
if(s>=48 &&s<=57){
return true;
}
return false;
}
}