标签:list code pack int pac public delete ems oid
package 链表;
/**
* https://leetcode-cn.com/problems/delete-node-in-a-linked-list/
* 237. 删除链表中的节点
*
* 解题思路 :使用给定节点的后一个节点的值覆盖给定节点的值,然后删除下一个节点
*/
public class _237_Delete_Node_in_a_Linked_List {
public class ListNode {
int val;
ListNode next;
ListNode(int x) {
val = x;
}
}
public void deleteNode(ListNode node) {
node.val = node.next.val;
node.next = node.next.next;
}
}
标签:list code pack int pac public delete ems oid
原文地址:https://www.cnblogs.com/jianzha/p/12810605.html