Easy Lists

Remove Duplicates (Singly Linked List)

Receives an array of integers and builds a singly linked list, where each node holds a value and a next pointer to the following node. It walks the list from head to tail using a set to track seen values; the first occurrence of each value is kept and any later duplicate node is unlinked by redirecting its predecessor's next pointer. Returns the head of the filtered list with each value appearing exactly once, preserving the original order.

Visualization

Input

Algorithm code

Custom input

Saved inputs

References