给定链表的表头节点head,实现删除链表的中间节点的函数 推展: 给定链表的头节点,整数a 和 整数 b,实现删除a/b处节点的函数 先来分析原问题, 长度1 直接返回 长度2 将头节点删除 长度3 删除第二个 长度4 删除第二个 长度5 删除第三个......长度每增加2 删除的节点就向后移动一个节点 如果要删除一个节点,则需要找到待删除节点的前一个节点 package TT; public class Test87 { public class Node{ public int val
Write a function to delete a node (except the tail) in a singly linked list, given only access to that node. Given linked list -- head = [4,5,1,9], which looks like following: Example 1: Input: head = [4,5,1,9], node = 5 Output: [4,1,9] Explanation: