A JS solution..

  • 5
    var deleteNode = function(node) {
        if(node.val !== undefined && node.next !== undefined){
            //copy the next node to this node
            node.val = node.next.val;
            node.next = node.next.next;

  • 0

    Why do we need to check node.val & node.next exist??
    It seem to be existed obviously when "node" is an input for our function.

Log in to reply

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