Two Lines Java Solution With Regex


  • 0
    C
    public class Solution {
        public boolean isPalindrome(String s) {
    	s = s.toLowerCase().replaceAll("[^\\w]", "");
    	return new StringBuilder(s).reverse().toString().equals(s);
        }
    }
    

Log in to reply
 

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