Delete Node in a Linked List
Solution ApproachWas this helpful?
Easy•linked-list•Expected: O(1) time, O(1) space
linked-list
Problem
Given only access to a node in a singly linked list (not the tail), delete that node.
Example 1:
Input: head = [4, 5, 1, 9], node = 5
Output: [4, 1, 9]
Explanation: Copy the next node's value into the given node and skip the next node.
Example 2:
Input: head = [4, 5, 1, 9], node = 1
Output: [4, 5, 9]
Reference solution unlocks after your first submission
Loading...
