Write a function to delete a node (except the tail) in a singly linked list, given only access to that node.
Supposed the linked list is 1 -> 2 -> 3 -> 4
and you are given the third node with value 3
, the linked list should become 1 -> 2 -> 4
after calling your function.
思路:单向链表,只给出要删除的结点的指针。因为我们无法获得要删除的节点的上一个结点的地址,所以就把要删除结点的下一个结点的值复制到要删除的节点,然后删掉要删除结点的下一个结点。