基础
框架
工程化
后端
Vocabulary
Reading
Listening
LeetCode 中等
题目
有一个单链表的 head,我们想删除它其中的一个节点 node。 给你一个需要删除的节点 node 。你将 无法访问 第一个节点 head。 链表的所有值都是 唯一的,并且保证给定的节点 node 不是链表中的最后一个节点。
O(1) O(1)
function deleteNode(node: Node | null): void { const next = node.next node.val = next.val node.next = next.next }