当前位置:网站首页>LeetCode 237. Delete nodes in the linked list

LeetCode 237. Delete nodes in the linked list

2022-07-05 03:00:00 Abby's daily life

https://leetcode-cn.com/problems/delete-node-in-a-linked-list/

Ideas

  1. Not really deleted , Instead, update the value of the node to be deleted to the value of the next node
  2. Delete the node next Updated to .next.next
 public void deleteNode(ListNode node) {
    
        node.val = node.next.val;
        node.next = node.next.next;
    }
原网站

版权声明
本文为[Abby's daily life]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202140829518479.html