My simple javascript solution


  • 0
    K
    var isPalindrome = function(s) {
    if(!s)return true;
    s=s.trim().toLowerCase().replace(/[^a-z0-9]/g, "");
    console.log(s);
    
    var start=0;
    var end=s.length-1;
    while(start < end)
    {
        if(s[start]==s[end])
        {
            start++;
            end--;
        }
        else return false;
    }
    
    return true;
    

    };


Log in to reply
 

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