125 Valid Palindrome – Easy
Problem:
Thoughts:
Solutions:
public class Solution {
public boolean isPalindrome(String s) {
if (s == null || s.equals("")){
return true;
}
s = s.toLowerCase();
s = s.replaceAll("[^A-Za-z0-9]","");
int i = 0;
int j = s.length() -1;
for (; i < j; i ++, j --){
if (s.charAt(i) != s.charAt(j)){
return false;
}
}
return true;
}//isPalindrome
}Last updated