You are given the heads of two sorted linked lists list1 and list2.
Merge the two lists in a one sorted list. The list should be made by splicing together the nodes of the first two lists.
Return the head of the merged linked list.
Run through both lists at once and determine the sorted order.
Set the head of the merged linked list to be the smaller of the two heads from list 1 and list 2
Repeat until there are no more nodes left in either list 1 or list 2
Find the smallest element
Append to the list
Append the rest of either list 1 or list 2
For example: list1 = [1 --> 2 --> 3 --> 5], list2 = [2 --> 4 --> 6 --> 7]
Set the head to be the smaller: merge = [1]
Next smallest node = [2] from list1; merge = [1 --> 2]
Next smallest node = [2] from list2; merge = [1 --> 2 --> 2]
Next smallest node = [3] from list1; merge = [1 --> 2 --> 2 --> 3]
Next smallest node = [4] from list2; merge = [1 --> 2 --> 2 --> 3 --> 4]
Next smallest node = [5] from list1; merge = [1 --> 2 --> 2 --> 3 --> 4 --> 5]
Since list1 has reached the end, append the rest of list2 to the end of merge.
merge = [1 --> 2 --> 2 --> 3 --> 4 --> 5 --> 6 --> 7]