Easy · Linked Lists

Delete Node

Given only a reference to a node of a singly linked list that is not the tail (in the samples, the node at 0-based index target), delete it in place without access to the head; afterwards the list must read as before with exactly that node's value removed.

Examples

Example 1

[4,5,1,9] delete idx 1

Output: [4,1,9]

Example 2

[1,2,3,4] delete idx 0

Output: [2,3,4]

Rebuild it in the studio

Core interview problems are free with a full runner and lessons; Pro opens the complete library.

More Linked Lists problems