题目描述
blablabla
样例
blablabla
对刷完剑指offer就改名老哥的题解的一点改动
算法1
python 代码
class Solution(object):
def merge(self, l1, l2):
"""
:type l1: ListNode
:type l2: ListNode
:rtype: ListNode
"""
dummy = ListNode(-1)
cur = dummy
while l1 and l2:
if l1.val<=l2.val:
cur.next = l1
l1 = l1.next
elif l2.val < l1.val:
cur.next = l2
l2 = l2.next
cur = cur.next
while l1:
cur.next = l1
l1 = l1.next
cur = cur.next
while l2:
cur.next = l2
l2 = l2.next
cur = cur.next
return dummy.next