list 1
list 2
1
2
4
1
3
4
[0][1][2][3][4][5]
collected
Naive · collect + sort
▸1vals ← all values of both lists2sort(vals)3rebuild a list from vals
state
- l1[1,2,4]
- l2[1,3,4]
Your free access ends in 7 days — and you haven’t tried it yet. Watch one algorithm run, start to finish. It takes about two minutes.
Try one problemMerge two sorted linked lists into one sorted list by splicing their nodes together, and return its head.
▸1vals ← all values of both lists2sort(vals)3rebuild a list from vals
line 1Merge two SORTED lists into one sorted list. Lazy way: dump every value into an array and sort it.