题目描述

输入两个单调递增的链表,输出两个链表合成后的链表,当然我们需要合成后的链表满足单调不减规则。
 class Solution:
# 返回合并后列表
def Merge(self, pHead1, pHead2):
# write code here
if pHead1==None:
return pHead2
if pHead2==None:
return pHead1
head=ListNode(-1)
head.next=None
root=head
while pHead1 is not None and pHead2 is not None:
if pHead1.val<pHead2.val:
head.next=pHead1
head=pHead1
pHead1=pHead1.next
else:
head.next=pHead2
head=pHead2
pHead2=pHead2.next
if pHead1 is None:
head.next=pHead2
else:
head.next=pHead1
return root.next

最新文章

  1. iOS---iOS10适配iOS当前所有系统的远程推送
  2. 关于input的file框onchange事件触发一次失效的新的解决方法
  3. I’m Sure It Will Only Take You A Few Days To Code
  4. IOS在线安装App
  5. Hybrid框架UI重构之路:五、前端那点事儿(HTML、CSS)
  6. php 购物车的例子
  7. NandFlash详述【转】
  8. PyPI镜像网站
  9. winserve2008下不能运行winXP下开发的应用程序→更改“兼容性”
  10. jquery初学者易犯的错误
  11. bzoj 2623 所罗门的咒语
  12. python遗产
  13. 在Linux与Windows上获取当前堆栈信息
  14. xmanager无法弹出图形化界面。
  15. 解决 ASP.NET Core Hangfire 未授权(401 Unauthorized)
  16. 【LeetCode每天一题】Set Matrix Zeroes(设置0矩阵)
  17. Fluentd初探 简介与安装
  18. vue 渲染函数&amp;jsx
  19. Hyper-v带宽限制以及验证工具
  20. sublime 3插件推荐

热门文章

  1. 互联网高级Java面试总结
  2. Long数组转String数组
  3. iOS之查看代码运行的时间
  4. git简单配置
  5. php第四节(循环和函数)
  6. harbor中碰到的问题
  7. LeetCode-环形链表II
  8. Git基本使用及工具
  9. PyCharm+QT Designer整合
  10. PHP icov转码报错解决方法,iconv(): Detected an illegal character in input string