删除链表中的节点 (Delete Node in a Linked List)

 

思路:

// @Title: 删除链表中的节点 (Delete Node in a Linked List)
// @Author: qisiii
// @Date: 2022-02-28 20:35:06
// @Runtime: 0 ms
// @Memory: 40.8 MB
// @comment: 
// @flag: 
/**
 * Definition for singly-linked list.
 * public class ListNode {
 *     int val;
 *     ListNode next;
 *     ListNode(int x) { val = x; }
 * }
 */
class Solution {
    public void deleteNode(ListNode node) {
        node.val=node.next.val;
        node.next=node.next.next;
    }
}
Licensed under CC BY-NC-SA 4.0
最后更新于 2024-10-18