#83

Remove Duplicates from Sorted List

pupil · 400 · lc easy +24 · verified · 56.3% accepted · 9,817 likes · top 50%

play →

Description

Remove extra duplicate nodes from sorted linked list head so every value appears exactly once. Return the head of the deduplicated list.

Example 1:

Input: head = [1,1,2]
Output: [1,2]

Example 2:

Input: head = [1,1,2,3,3]
Output: [1,2,3]

Code

1
2
3
4
5
6
7
8