标签:while return lse pytho tno turn style 合并两个排序的链表 题目
1 class Solution: 2 # 返回合并后列表 3 def Merge(self, pHead1, pHead2): 4 # write code here 5 dummy =p = ListNode(-1) 6 while pHead1 and pHead2: 7 if pHead1.val < pHead2.val: 8 p.next=ListNode(pHead1.val) 9 pHead1 = pHead1.next 10 else: 11 p.next=ListNode(pHead2.val) 12 pHead2 = pHead2.next 13 p = p.next 14 if pHead2: 15 pHead1=pHead2 16 p.next=pHead1 17 return dummy.next
2019-12-08 08:58:27
标签:while return lse pytho tno turn style 合并两个排序的链表 题目
原文地址:https://www.cnblogs.com/NPC-assange/p/12004589.html