125. Valid Palindrome

class Solution {
    public boolean isPalindrome(String s) {
	String lowerCase = s.toLowerCase();
	String target = lowerCase.replaceAll("[^a-z0-9]", "");
	for (int i = 0 ; i < target.length()/2 ; i++){
		if (target.charAt(i) != target.charAt(target.length()-1-i)){
			return false;
		}
	}
	return true;
    }
}

Last updated

Was this helpful?