Search⌘ K
AI Features

Problem: Merge Two Sorted Lists

Understand how to merge two sorted linked lists by iteratively comparing nodes and using a dummy node for simplified list construction. Learn the pointer manipulation techniques and analyze the solution's time and space efficiency.

Statement

Given the heads of two sorted linked lists, list1 and list2, merge them into a single sorted linked list by splicing together the nodes from both input lists.

Return the head of the resulting merged linked list.

Note: Both list1 and list2 are sorted in non-decreasing order.

Constraints:

  • The number of nodes in each list is in the range [0,50][0, 50].

  • 100-100 \leq ...