30:00
Given the head of a sorted linked list, delete all duplicates such that each element appears only once. Return the linked list sorted as well.
The number of nodes in the list is in the range [0,300][0, 300][0,300].
−100≤Node.val≤100-100 \leq \text{Node.val} \leq 100−100≤Node.val≤100
The list is guaranteed to be sorted in ascending order.
Run code to see results.
The list is sorted, so every copy of a value sits right next to the others.
Unlinked duplicates (0)
none yet
List from head right now
[1, 1, 2]
You get the head of a singly linked list sorted in non-decreasing order. Remove the extra copies so that each value appears once, keep the list sorted, and return its head.