标签:规则 none class 需要 one 合并两个排序的链表 nod list merge
# -*- coding:utf-8 -*- # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: # 返回合并后列表 def Merge(self, pHead1, pHead2): # write code here if pHead1 == None: return pHead2 elif pHead2 == None: return pHead1 pMergedHead = None if pHead1.val < pHead2.val: pMergedHead = pHead1 pMergedHead.next = self.Merge(pHead1.next,pHead2) else: pMergedHead = pHead2 pMergedHead.next = self.Merge(pHead1, pHead2.next) return pMergedHead
标签:规则 none class 需要 one 合并两个排序的链表 nod list merge
原文地址:https://www.cnblogs.com/tianqizhi/p/9674180.html