The Remove Duplicates from Sorted List interview question asks you to traverse a sorted singly linked list and delete all nodes that contain duplicate values, keeping only one occurrence of each value. Because the list is already sorted, all duplicates are guaranteed to be adjacent, making this a clean and elegant application of basic linked list pointer manipulation.
This problem is asked at Apple, Microsoft, Meta, Amazon, Google, and Bloomberg as an entry-level linked list question. It evaluates whether a candidate understands pointer traversal, the concept of in-place node deletion, and edge case handling (empty list, all duplicates). It is a foundational exercise that builds the intuition needed for more complex linked list problems like reversals and merges.
The pattern is single-pass linked list traversal with direct pointer manipulation. Use a single pointer curr starting at the head. At each step, compare curr.val with curr.next.val. If they match, skip curr.next by setting curr.next = curr.next.next. If they don't match, advance curr to curr.next. Continue until curr or curr.next is null.
List: 1 → 1 → 2 → 3 → 3
1 → 2 → 3 → 3.1 → 2 → 3.Result: 1 → 2 → 3.
curr when a duplicate is found instead of staying at the current node to handle consecutive duplicates (e.g., 1 → 1 → 1).curr.next before accessing curr.next.val, causing null pointer errors.For the Remove Duplicates from Sorted List coding problem, the linked list interview pattern is straightforward once you internalize the key rule: only advance your pointer when the current node is confirmed unique. Practice tracing through a list with three or more consecutive duplicates to verify your loop handles them all. Interviewers at Revolut and Nvidia use this as a warm-up to lead into Remove Duplicates from Sorted List II, so be ready for the follow-up.
| Title | Difficulty | Topics | LeetCode |
|---|---|---|---|
| Delete N Nodes After M Nodes of a Linked List | Easy | Solve | |
| Delete Node in a Linked List | Medium | Solve | |
| Reverse Linked List II | Medium | Solve | |
| Split Linked List in Parts | Medium | Solve | |
| Odd Even Linked List | Medium | Solve |