1 public class Solution { 2 public boolean isPalindrome(String s) { 3 // IMPORTANT: Please reset any member data you declared, as 4 // the same Solution instance will be reused for each test case. 5 if(s == null || s.length() < 2) 6 return true; 7 String mystring = s.replaceAll("[^A-Za-z0-9]",""); 8 mystring = mystring.toLowerCase(); 9 for(int i = 0; i < (mystring.length() / 2); i++) 10 if(mystring.charAt(i) != mystring.charAt(mystring.length() - 1 - i)) 11 return false; 12 return true; 13 } 14 }