Medium

Quiz

#82 Remove Duplicates from Sorted List II

APPROACH

Delete all nodes from sorted linked list head whose values appear more than once, keeping only nodes with values that occur exactly once. Return the resulting sorted list.

Example 1:

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

Example 2:

Input: head = [1,1,1,2,3]
Output: [2,3]
1 of 4
1:00

What is the optimal approach for this problem?