Merge lists into a sorted list
MediumLet's say you're given two linked lists of sorted numbers.
Write a function that merges the two linked lists into a single sorted linked list.
For example, given the two linked lists below:
# Inputs(1) -> (3) -> (4) -> (7)(2) -> (4) -> (6) -> (9)
The output should be the following linked list:
# Output(1) -> (2) -> (3) -> (4) -> (4) -> (6) -> (7) -> (9)
Try it first
Solution
8 Essential Linked Lists Coding Interview Problems
Master Linked Lists by trying the coding challenges below.
- 1.Insert NodeEasy
- 2.Remove NodeEasy
- 3.Find the MiddleEasy
- 4.Add Linked ListsEasy
- 5.Reverse Linked ListMedium
- 6.Detect CycleMedium
- 7.Merge Linked ListsMedium
- 8.Pivot Linked ListHard