Share my solution java w/ regex


  • 0
    Z
        public static boolean isPalindrome(String s) {
            String s2 = s.replaceAll("\\W", "").toLowerCase();
            StringBuffer s3 = new StringBuffer();
            s3.append(s2);
            s3.reverse();
            return s3.toString().equals(s2);
        }

Log in to reply
 

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