Merge Two Sorted Lists
Try to solve the Merge Two Sorted Lists problem.
We'll cover the following
Statement#
Given the heads of two sorted linked lists, list1 and list2, merge these lists into a single sorted list. This involves integrating all the nodes from both lists while ensuring that their sorted order is preserved. Return the head of the merged linked list as the output.
Constraints:
- Number of nodes in both lists 
- Node.data
- Both lists are sorted in a non-decreasing order. 
Examples#
1 of 3
2 of 3
3 of 3
Understand the Problem#
Let’s take a moment to make sure you’ve correctly understood the problem. The quiz below helps you check if you’re solving the correct problem:
Merge Two Sorted Lists
What is the output if the following lists are given as input?
= → → →
= → → →
→
→ → →
→ → → → →
→ → → → → →
Figure it out!#
We have a game for you to play. Rearrange the logical building blocks to develop a clearer understanding of how to solve this problem.
Try it yourself#
Implement your solution in main.py in the following coding playground. We have provided a few useful code templates in the other files that you may build on to solve this problem.
K-way Merge: Introduction
Solution: Merge Two Sorted Lists