Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.
思路
递归最容易实现,根据l1和l2头节点数据域的大小,决定合并后链表的头结点,这样问题的规模减1,递归直到满足其中的3个返回条件的中的一个: if l1==None and l2==None: return None if l1==None: return l2 if l2==None: return l1
Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.思路 递归最容易实现,根据l1和l2的头元素大小,决定头元素的指向,这样问题的规模减1,递归直到满足其中的3个返回条件