Merge Two Sorted Lists
You are given the heads of two sorted linked lists, list1 and list2.
Merge the two lists into one sorted linked list by splicing together the nodes of the first two lists.
Return the head of the merged linked list.
Example 1
Input
list1 = [1,2,4] list2 = [1,3,4]
Output
[1,1,2,3,4,4]
Explanation
Both lists are already sorted. We repeatedly select the smaller current element from the two lists.
Example 2
Input
list1 = [] list2 = [0]
Output
[0]
Explanation
The first list is empty, so the merged list is simply the second list.
Constraints
Hints:
Hint 1
Use two pointers, one for each linked list.
Hint 2
Compare the current nodes of both lists and attach the smaller node to the merged list.
Author & Technical Reviewer
Technically reviewed by: ExamAdda Technical Review Team
Technical Reviewers, ExamAdda
Software engineers at ExamAdda who check every article's definitions, complexity claims and code examples before and after publishing.
Published
Aug 10, 2026
Last updated
Aug 11, 2026
Content Verification Methodology
Definitions and complexity claims were checked against authoritative computer-science references. Code examples were compiled and tested with standard, boundary and edge-case inputs.
Expected Output