Remove Duplicates
LINKED LIST

Problem

Given the head of a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.

Return the linked list sorted as well.

Examples

deleteDuplicates([1,2,2,2,3,4,4,5]); // returns [1,3,5] // 2 and 4 are repeated so they // are removed from the final list
Loading...
1
2
2
2
3
4
4
5