DEV Community

Karleb
Karleb

Posted on

#237. Delete Node in a Linked List

https://leetcode.com/problems/delete-node-in-a-linked-list/?envType=daily-question&envId=2024-05-05


/**
 * 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.
 */
var deleteNode = function (node) {
    node.val = node.next.val
    node.next = node.next.next
};

Enter fullscreen mode Exit fullscreen mode

Top comments (0)