AFFILIATE LINKS
Great resource I use to learn algorithms.
40% off Tech Interview Pro: http://techinterviewpro.com/terriblewhiteboard
20% off CoderPro: http://coderpro.com/terriblewhiteboard
Here is the full implementation.
/**
* Definition for singly-linked list.
* function ListNode(val) {
* this.val = val;
* this.next = null;
* }
*/
/**
* @param {ListNode} node
* @return {void} Do not return anything, modify node in-place instead.
*/
let deleteNode = function(node) {
/* replace current node's value with the same values as the next node */
node.val = node.next.val;
/* eliminate the next node by re-assigning the pointer that references it to instead point to the node after it */
node.next = node.next.next;
};