← Return

Delete Duplicate-Value Nodes from a Sorted Linked ListEasy

This challenge is part of a tutorial track by MyCodeSchool

You are given the pointer to the head node of a sorted linked list, where the data in the nodes is in ascending order. Delete nodes and return a sorted list with each distinct value in the original list. The given head pointer may be null indicating that the list is empty.

Example

\(head\) refers to the first node in the list \(1 \to 2 \to 2 \to 3 \to 3 \to 3 \to 3 to NULL\).

Remove 1 of the \(2\) data values and return \(head\) pointing to the revised list \(1 \to 2 \to 3 \to NULL\).