#5

Merge Two Sorted Lists

Easy
All Problems

5. Merge Two Sorted Lists#21

Easy🔗 Linked ListTwo-Pointer Merge

Merge two sorted linked lists into one sorted linked list.

Examples

Example 1:
Input: [[1,2,4],[1,3,4]]
Output: [1,1,2,3,4,4]
Example 2:
Input: [[],[]]
Output: []
Example 3:
Input: [[],[0]]
Output: [0]

Why learn this

First exposure to linked list manipulation. The merge logic appears everywhere (merge sort, etc.).

Linked ListsRecursionMerge Pattern
Python 3Loading Python engine...
Click "Run Code" to test your solution