32/39
Part 7 of 7 · Follow-upsLearn and do

How do you merge two sorted lists?

Use a dummy head and a tail pointer, then relink the smaller front node each time:

print(values(merge_two(linked([1, 4, 4, 9]), linked([2, 4, 10]))))
Predict

merge_two takes from b only when b.val < a.val. Of the three 4s, which come first?

Pick one to see what it prints.
Pick an answer above to see the rest