3 lines simple java solution


  • 0
    A
    class Solution {
     public boolean isPalindrome(String s) {
        s = s.toLowerCase().replaceAll("[^a-z0-9]", "");
        String r = new StringBuilder(s).reverse().toString();
        return s.equals(r) ? true : false;
        
    }
    
    }

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.