剑指Offer 25
Posted asenyang
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了剑指Offer 25相关的知识,希望对你有一定的参考价值。
1 # -*- coding:utf-8 -*- 2 # class ListNode: 3 # def __init__(self, x): 4 # self.val = x 5 # self.next = None 6 class Solution: 7 # 返回合并后列表 8 def Merge(self, pHead1, pHead2): 9 if pHead1 == None: 10 return pHead2 11 if pHead2 == None: 12 return pHead1 13 if pHead1.val <= pHead2.val: 14 pHead1.next = self.Merge(pHead1.next,pHead2) 15 return pHead1 16 else: 17 pHead2.next = self.Merge(pHead1,pHead2.next) 18 return pHead2 19 # write code here
以上是关于剑指Offer 25的主要内容,如果未能解决你的问题,请参考以下文章