list1 and list2 are linked lists sorted in increasing order. Merge them into one sorted list by re-using their nodes, and return its head.
The tests show a list as a Python list of its values: [1, 2, 3] stands for 1 -> 2 -> 3.
Example 1
Input:
merge_two_lists(list1, list2) # list1 = 1 -> 2 -> 4, list2 = 1 -> 3 -> 4
Output:
[1, 1, 2, 3, 4, 4]
Example 2
Input:
merge_two_lists(list1, list2) # list1 = empty, list2 = 0
Output:
[0]
0 <= nodes in each list <= 100000-10**9 <= val <= 10**9No results yet
Run your code to check it against the examples, or submit to run every test.