码迷,mamicode.com
首页 > 其他好文 > 详细

剑指Offer 25

时间:2019-06-12 22:59:21      阅读:82      评论:0      收藏:0      [点我收藏+]

标签:list   nod   class   lis   剑指offer   ret   bsp   lse   off   

 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

标签:list   nod   class   lis   剑指offer   ret   bsp   lse   off   

原文地址:https://www.cnblogs.com/asenyang/p/11013124.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!