← All problems
Merge Two Sorted Lists
Merge two sorted singly linked lists into a single sorted linked list, reusing the existing nodes (no new allocations except a dummy head). Return the head of the merged list.
Complexity
Time O(n+m), Space O(1) iterative
Common pitfalls
- Losing the head (no dummy)
- Not handling exhausted lists
Your solution
Log in to save your code and track progress.