Merge two sorted linked lists into one sorted list by splicing their nodes together. Return the merged head.
The smaller head goes first; its next is the merge of the remaining nodes.
1function mergeTwoLists(a: ListNode | null, b: ListNode | null): ListNode | null {2if (!a) return b;3if (!b) return a;4if (a.val <= b.val) { a.next = mergeTwoLists(a.next, b); return a; }5b.next = mergeTwoLists(a, b.next);6return b;7}
1 ≤ 1: 1 goes first.
Space: play/pause · ←/→: step