Problem
You get list1 and list2, the heads of two linked lists. A linked list is a chain of nodes, and each node links to the next node.
The values in each list are in non-decreasing order. Thus, each value is equal to or greater than the value before it.
Merge the two lists into one list in non-decreasing order. Use the nodes of the two lists, and do not make new nodes. Return the head of the merged list.
Example 1
- Input:
- list1 = [2,5,9], list2 = [1,5,6]
- Output:
- [1,2,5,5,6,9]
Example 2
- Input:
- list1 = [], list2 = [4]
- Output:
- [4]
- Explanation:
- The first list is empty, so the result is the second list.
Example 3
- Input:
- list1 = [], list2 = []
- Output:
- []
Constraints
- The number of nodes in each list is in the range [0, 50].
- -100 <= Node.val <= 100
- list1 and list2 are in non-decreasing order.
SysRound wrote this statement. A reference solution checks every example.
Related questions
Continue with questions that share topics or the same question type.
- Add Two Numbers
Coding · Linked List · Math · Recursion
- Palindrome Linked List
Coding · Linked List · Recursion · Stack
- Reverse Linked List
Coding · Linked List · Recursion
- Reverse Nodes in k-Group
Coding · Linked List · Recursion
Sources · 2 references
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 3 records
LinkedIn
Leetcode 21. Merge Two Sorted Lists
Reported Mar 3, 2025 · 1 source report
SENIOR
Source snapshot: Nov 12, 2026
View sourceMeta
Leetcode 21. Merge Two Sorted Lists
Reported Feb 23, 2026 · 6 source reports
MID_LEVEL, SENIOR
Source snapshot: Nov 12, 2026
View sourceWaymo
Leetcode 21. Merge Two Sorted Lists
Reported Jan 17, 2026 · 1 source report
MID_LEVEL
Source snapshot: Nov 12, 2026
View source
LeetCode company tags · 5 records
Adobe
Merge Two Sorted Lists
Reported date not specified · Source window: 6mo