LeetCode-237-删除链表中的节点
题目描述
请编写一个函数,使其可以删除某个链表中给定的(非末尾)节点。传入函数的唯一参数为 要被删除的节点 。
解法
public void deleteNode(ListNode node) {
node.val = node.next.val;
node.next = node.next.next;
}
运行结果:
标题:LeetCode-237-删除链表中的节点
作者:guobing
地址:http://guobingwei.tech/articles/2020/11/08/1604766106712.html