Problem
You get the head of a linked list sorted in ascending order. Remove nodes so that each value appears only once, keeping the first node of every run of equal values, and return the head. The result stays sorted.
Example 1
- Input
- 1
- Output
- 1 -> 2 → 1 -> 2
Example 2
- Input
- 1
- Output
- 1 -> 2 -> 3 -> 3 → 1 -> 2 -> 3
Example 3
- Input
- (empty)
- Output
- (empty)
Constraints
0 <= number of nodes <= 300-100 <= Node.val <= 100The list is sorted in ascending order.