← 返回 pinterest 的题目列表Delete Node in a Linked List
类型:online_judge
Write a function to delete a node in a linked list. You will not be given access to the head of the list, instead you will be given access to the node to be deleted directly. It is guaranteed that the node to be deleted is not a tail node in the list. Assume the linked list has at least two elements, and all the node values are unique. Your solution should have a time complexity of O(1).
Example:
Input: a linked list 4 -> 5 -> 1 -> 9 and the node to be deleted 5 Output: linked list becomes 4 -> 1 -> 9
Example
Input
4
5
1
9
5