Remove Duplicates from Sorted List Visualization & Animation
Removes consecutive duplicate nodes from a sorted linked list in-place; O(n) time, O(1) space.
## What is it?
Remove all duplicate nodes from a sorted singly linked list so that each value appears only once.
## How it works
- Use a single pointer `curr` starting at `head`
- If `curr.val == curr.next.val` → skip `curr.next` by setting `curr.next = curr.next.next`
- Otherwise → advance `curr = curr.next`
- Repeat until `curr.next == null`
## When to use
- Deduplication of sorted data in a linked list
- Pre-processing step in merge/sort algorithms on lists
- Variant: "Remove all duplicates" (delete every node with a duplicate value, not just the extra copies)
## Key Points
- Works only on **sorted** lists — duplicates are guaranteed to be adjacent
- O(n) time, O(1) space — in-place pointer manipulation
- The node itself is not freed in garbage-collected languages; just its reference is removed