This simple solution is giving me time limit exceeded. What is wrong ?


  • 0
    P

    var isPalindrome = function(s) {
    if(!s)return true;
    s=s.trim().toLowerCase().replace(/[^a-z0-9]/g, "");
    // console.log(s);
    var n=s.length-1;
    return n < 1 || s[0] == s[n] && isPalindrome(s.substring(1,n));
    };


Log in to reply
 

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