← 返回 snowflake 的题目列表Merge Two Sorted Lists
类型:qbank
You are given the heads of two sorted linked lists list1 and list2.
Merge Two Sorted Lists
You are given the heads of two sorted linked lists list1 and list2.
SWE
linked-list
merge
recursion
easy
Frequency
Single report
Last asked
2026-01-20
Stage
phone-screen · onsite-coding
Merge Two Sorted Lists
Problem Statement
You start with the head nodes of two linked lists, labeled list1 and list2. Both of these lists are already sorted.
Your task is to combine these two lists into one single linked list that is also sorted. You must return the head of this newly merged list. The final list should consist of the specific nodes found in list1 and list2.
Test Cases
Case 1:
Input: list1 = [1,2,4], list2 = [1,3,4]
Output: [1,1,2,3,4,4]
Case 2:
Input: list1 = [], list2 = []
Output: []
Case 3:
Input: list1 = [], list2 = [0]
Output: [0]
Technical Constraints
The total number of nodes in each list is between 0 and 50.
The value of each Node is between -100 and 100.
Both list1 and list2 are sorted in non-decreasing order (from lowest to highest).