【剑指offer】Q17:合并两个排序的链表
2017-08-04 10:12
351 查看
def Merge(head1, head2): if head1 == None: return head2 if head2 == None: return head1 psuhead = ListNode(-1) tail = psuhead while head1 and head2: if head1.val < head2.val: cur = head1 head1 = head1.next else: cur = head2 head2 = head2.next cur.next = tail.next tail.next = cur tail = cur Print(psuhead) # link the rest nodes if head1 == None: head1 = head2 tail.next = head1 head1 = psuhead.next del psuhead psuhead = None return head1
相关文章推荐
- 【剑指offer】Q17:合并两个排序的链表
- 剑指offer 面试题17: 合并两个排序的链表 题解
- 剑指offer 合并两个排序的链表
- 剑指offer之十五---合并两个排序的链表
- 剑指offer之面试题17合并两个排序的链表
- LintCode-剑指Offer-(165)合并两个排序链表
- 【剑指Offer学习】【面试题17 ::合并两个排序的链表】
- 剑指offer面试题17——合并两个排序的链表
- 剑指offer-面试题17.合并两个排序的链表
- 剑指 Offer —16—合并两个排序的链表
- 17.合并两个排序的链表|剑指Offer
- 剑指Offer:面试题17——合并两个排序的链表
- 剑指Offer-合并两个排序的链表
- 剑指offer——16.合并两个排序的链表
- 剑指Offer:反转链表、合并两个排序的链表
- [九度OnlineJudge][剑指Offer]题目1519:合并两个排序的链表
- [剑指offer]合并两个排序的链表
- 【剑指offer-Java版】17合并两个排序链表
- 剑指offer--合并两个排序的链表
- 剑指offer-合并两个排序的链表