Given the head of a sorted linked list, delete all duplicates such that each element appears only once and return the updated head. Example: Input: head = [1,1,2] Output: [1,2] Explanation: We remove the extra '1' from the list. Pattern focus: Dummy Head Node technique (simplifies deletions).
head = ListNode
return ListNode
Example 1:
Input:
head = [1,1,2]
Output:
[1,2]
Explanation:
Remove the extra 1 to leave [1,2].
Example 2:
Input:
head = [1,1,2,3,3]
Output:
[1,2,3]
Explanation:
Duplicate 1 and 3 are removed.