public boolean isPalindrome(String s) {
if (s == null || s.trim().length() <= 1) return true;
s = s.toLowerCase();
for (int i = 0, j = s.length()-1; i < j;) {
if (!isLetterOrDigit(s.charAt(i))) i++;
else if (!isLetterOrDigit(s.charAt(j))) j--;
else {
if (s.charAt(i) != s.charAt(j)) return false;
i++;
j--;
}
}
return true;
}
private boolean isLetterOrDigit(char c) {
if (c >= 'a' && c <= 'z') return true;
if (c >= '0' && c <= '9') return true;
return false;
}
06-19
144