Skip to content

Latest commit

 

History

History
25 lines (21 loc) · 588 Bytes

0237. 删除链表中的节点.md

File metadata and controls

25 lines (21 loc) · 588 Bytes

237. 删除链表中的节点

请编写一个函数,使其可以删除某个链表中给定的(非末尾)节点。传入函数的唯一参数为 要被删除的节点 。

https://leetcode-cn.com/problems/delete-node-in-a-linked-list/


/**
 * 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
};