The problem. Given the head of a sorted linked list, delete every duplicate so each value appears only once. Return the list, still sorted.
Input: head = [1, 1, 2]
Output: [1, 2]
Input: head = [1, 1, 2, 3, 3]
Output: [1, 2, 3]The word sorted is the hint. In a sorted list, all copies of a value sit next to each other.
Free account
Sign up to read the rest of this lesson: 5 more sections, 2 drawings, a dry-run simulator and code in JavaScript, Python, Java and C++.
Still to come