leet237- Delete Node in a Linked List

难度:easy

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.

思路:一道get不到重点的题目,要求在不知道首表的条件下,删除链表中的一个node。一般删除节点是通过上一个节点来操作的。由于此题中只有当前节点,于是就将当年节点的值赋予下一位节点,然后删除下一个节点。----下一个节点死的真冤。


leet237- Delete Node in a Linked List