You get two linked lists, list1 and list2, and each of them is already sorted. Build one sorted list that holds all their nodes, by reusing those nodes instead of creating new ones. Return the head of this list.
How the judge passes the data
Examples
Example 1:
Input: list1 = [2,6,9], list2 = [1,6,10]
Output: [1,2,6,6,9,10]
Explanation: Take the smaller front value each time.
Example 2:
Input: list1 = [5], list2 = []
Output: [5]
Explanation: One list is empty, so the answer is the other list.
Example 3:
Input: list1 = [], list2 = []
Output: []
Explanation: Both lists are empty.