You've successfully subscribed to Nicholas Workshop
Great! Next, complete checkout for full access to Nicholas Workshop
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.
Success! Your billing info is updated.
Billing info update failed.

Remove Node from Singly Linked List

Nicholas Wong
Nicholas Wong

Question

How do you remove a node from a singly linked list, given only that node? Head node is not given.

Solution

Set next of this node to the next of the next node.

node->next = node->next->next;

Reference

Algorithm

Nicholas Wong

Fullstack software engineer with strong background in computer science and extensive experience in software engineering and architecture. Studied in NYU, worked in Yahoo, Rakuten and Manulife.