递归 与 正常想法
class Solution:
# 返回合并后列表
def Merge(self, pHead1, pHead2):
# write code here
h1=pHead1
h2=pHead2
result=ListNode(0)
if h1==None:
result=h2
#return result.next
if h2==None:
result=h1
#return result.next
if h1!=None and h2!=None:
if h1.val<=h2.val:
result=h1
result.next=self.Merge(h1.next,h2)
else:
result=h2
result.next=self.Merge(h1,h2.next)
return result
京公网安备 11010502036488号