My simple solution - no fast/slow runners (JS)


  • 0
    M
    var isPalindrome = function(head) {
        var arr = [];    
        while(head){
            arr.push(head.val);
            head = head.next;
        }
        
        var n = arr.length-1;
        for(var i = 0; i < n/2; i++){
            if(arr[i] !== arr[n-i]) return false;
        }
        
        return true;
    };
    

Log in to reply
 

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