Merge Two Sorted Lists
EasyRecursionTwo PointersLINKED_LISTSORTING
You are given the heads of two sorted singly linked lists, list1 and list2.
Merge the two lists into one sorted linked list, and return the head of the merged list.
You must do this by splicing together the nodes of the original lists — do not create new nodes.
Constraints:
The number of nodes in both lists is in the range [0, 50].
-100 ≤ Node.val ≤ 100
Both list1 and list2 are sorted in non-decreasing order.
Examples
Example 1
Input: [5,6,7],[1,2,3]
Output: [1,2,3,5,6,7]
Example 2
Input: [],[]
Output: []