Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.
public class Solution {
public int isPalindrome(String A) {
StringBuilder s = new StringBuilder();
for (int i = 0; i < A.length(); i++) {
if ((A.charAt(i) >= 'a' && A.charAt(i) <= 'z') || (A.charAt(i) >= 'A' && A.charAt(i) <= 'Z')
|| (A.charAt(i) >= '0' && A.charAt(i) <= '9'))
s.append(A.charAt(i));
}
String str = s.toString().toLowerCase();
int i = 0;
int j = str.length() - 1;
while (i < j) {
if (str.charAt(i) == str.charAt(j)) {
i++;
j--;
continue;
} else
return 0;
}
return 1;
}
}