Back to course home
0% completed
Solution: Merge Two Sorted Lists
Problem Statement
Given the head of two sorted linked lists, l1
and l2
.
Return a new sorted list created by merging together the nodes of the first two lists.
Examples
-
Example 1:
- Input:
[1, 3, 5] [2, 4, 6]
- Expected Output:
[1, 2, 3, 4, 5, 6]
- Justification: Merging the two sorted linked lists, node by node, results in a single sorted linked list containing all elements from both input lists.
- Input:
-
Example 2:
- Input:
[2, 4, 6] [1, 3, 5]
- Input:
.....
.....
.....
Like the course? Get enrolled and start learning!