LeetCode 237. Delete Node in a Linked List
程序员文章站
2024-02-17 10:36:40
...
在一个链表中,给定其中一个节点 (except the tail),输出为删除该节点的链表
如1→2→3→4→5
给定3的node,应输出1→2→4→5
【可修改链表】
直接用node.val = node.next.val node.next = node.next.next;
class Solution {
public void deleteNode(ListNode node) {
node.val = node.next.val;
node.next= node.next.next;
}
}
上一篇: Smarty保留变量用法分析
下一篇: LeetCode 66. 加一
推荐阅读
-
237. Delete Node in a Linked List
-
LeetCode笔记:237. Delete Node in a Linked List
-
237. Delete Node in a Linked List
-
LeetCode 237. Delete Node in a Linked List
-
237. Delete Node in a Linked List【力扣】
-
237. Delete Node in a Linked List
-
237. Delete Node in a Linked List
-
237. Delete Node in a Linked List
-
Leetcode--Reverse Linked List
-
【LeetCode OJ 328】Odd Even Linked List