1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
func mergeTwoLists(l1 *ListNode, l2 *ListNode) *ListNode { if l1 == nil {return l2} if l2 == nil {return l1}
if l1.Val < l2.Val{ l1.Next = mergeTwoLists(l1.Next,l2) return l1 }else{ l2.Next = mergeTwoLists(l1,l2.Next) return l2 }
}
|