Facebook Pixel
Merge Two Sorted Lists
Easy

Given two sorted linked lists, merge them into one sorted linked list and return the head of the merged list.

Example:

Input: list1 = [1,2,4], list2 = [1,3,4]
Output: [1,1,2,3,4,4]

Input: list1 = [], list2 = []
Output: []

Input: list1 = [], list2 = [0]
Output: [0]
Test Cases

Test Cases

Input
1 3 5
2 4 6
Expected Output
1 2 3 4 5 6
Step 1
Step 2
Step 3
Step 1: Identify the Pattern
Merge Two Sorted Lists
Easy

Given two sorted linked lists, merge them into one sorted linked list and return the head of the merged list.

Example:

Input: list1 = [1,2,4], list2 = [1,3,4]
Output: [1,1,2,3,4,4]

Input: list1 = [], list2 = []
Output: []

Input: list1 = [], list2 = [0]
Output: [0]
Test Cases

Test Cases

Input
1 3 5
2 4 6
Expected Output
1 2 3 4 5 6
Step 1
Step 2
Step 3
Step 1: Identify the Pattern