> For the complete documentation index, see [llms.txt](https://emmaguo100.gitbook.io/leetcode/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://emmaguo100.gitbook.io/leetcode/01-17-2022-17.md).

# 01/17/2022 17

&#x20;

Using recursion. if either of `l1` or `l2` is initially `null`, return the non-`null` list. Otherwise, we determine which of `l1` and `l2` has a smaller head, and recursively set the `next` value for that head to the next merge result.&#x20;

Time O(n+m)

Space O(n+m)

![](/files/MDA7VM2SSVfQPJdfwhck)
