Address: https://leetcode.cn/problems/delete-node-in-a-linked-list
Solution idea: idea: node is the node to be deleted, change the value of the second node to the value of the third node , that is, modify the value of node 5 to 1 and then point the value of the third node to empty
public class 删除链表中的节点 {
public class ListNode {
int val;
ListNode next;
ListNode(int x) {
val = x; }
}
public void deleteNode(ListNode node) {
node.val = node.next.val;
//node.next.next=null
node.next = node.next.next;
}
}