50. Merge Two Sorted Lists

Given the heads of two sorted singly linked lists list1 and list2. Merge them into one sorted list and return its head.
Example 1
Input: head = [], list2 = []
Output: []
Explanation: Both lists are empty, so the result is empty too.
Example 2
Input: head = [1,2,4], list2 = [1,3,4]
Output: [1,1,2,3,4,4]
Explanation: At each step, the smaller head from the two lists is taken.
easylinked list
JavaScript
Loading...
Line 1, Char 1