Remove Duplicates from Sorted List
EasyLinked List
Decode it first. Clues, constraints, pattern and plan before any code.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.
1 -> 1 -> 2 → 1 -> 2
1 -> 1 -> 2 -> 3 -> 3 → 1 -> 2 -> 3
(empty) → (empty)Constraints
0 <= number of nodes <= 300-100 <= Node.val <= 100- The list is sorted in ascending order.