Remove Duplicates from Sorted List II
MediumLinked List
Decode it first. Clues, constraints, pattern and plan before any code.You get the head of a linked list sorted in ascending order. Delete every node whose value appears more than once, so only values that were unique in the original list are left. Return the head of the result, which stays sorted.
1 -> 2 -> 3 -> 3 -> 4 -> 4 -> 5 → 1 -> 2 -> 5
1 -> 1 -> 1 -> 2 -> 3 → 2 -> 3
1 -> 1 → (empty)Return None (null in TypeScript) if nothing is left.
Constraints
0 <= number of nodes <= 300-100 <= Node.val <= 100- The list is sorted in ascending order.