Junior
Detailed answer
Linked Lists
DSA & Coding Interviews
Explain Merge Two Sorted Lists.
Short answer: Use a dummy head and append the smaller of the two current nodes until one list is exhausted, then attach the remainder. Recursive merge is elegant but uses stack space.
Complexity
Time O(n + m), Space O(1) iterative.
Common follow-ups
- Merge k sorted lists (heap / divide-and-conquer)
- Merge sorted arrays in-place
Dummy node avoids special-casing the head — a small habit that impresses interviewers.
Share this Q&A
Share preview image: https://www.toolliyo.com/images/toolliyo-logo.png