My JS simple solution


  • 0
    W
    var isPalindrome = function(s) {
    s = s.replace(/\W/g,'').toLowerCase()
    var i = 0, j = s.length-1
    console.log(i,j)
    while(i <= j)
     {
         if(s.charAt(i) !== s.charAt(j)) 
         	return false
         i++;
         j--;
         console.log(i,j)
     }
    
     return true
    

    };


Log in to reply
 

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