当前位置:网站首页>Linked list 4- 21 merge two ordered linked lists
Linked list 4- 21 merge two ordered linked lists
2022-06-22 18:50:00 【Artificial intelligence Zeng Xiaojian】

class Solution:
def mergeTwoLists(self, l1: ListNode, l2: ListNode) -> ListNode:
if l1 is None:
return l2
elif l2 is None:
return l1
elif l1.val < l2.val:
l1.next = self.mergeTwoLists(l1.next, l2)
return l1
else:
l2.next = self.mergeTwoLists(l1, l2.next)
return l2
class Solution:
def mergeTwoLists(self,l1:ListNode,l2:ListNode):
if l1 is None:
return l2
elif l2 is None:
return l1
elif l1.val< l2.val:
l1.next = self.mergeTwoLists(l1.next,
return l1
else:
l2.next= self.mergeTwoLists(l1,l2.next
return l2边栏推荐
- Network intelligent operation and maintenance helps improve operation and maintenance efficiency
- 国产手机干翻苹果?原来是靠百元机和猛降价实现的
- List的同步类比较
- A course for New Oriental transformation bilingual live broadcast to bring goods to the project manager
- exness整理马斯克收购推特需要解决三个问题
- RF Analyzer Demo搭建
- @“齐鲁多娇”幸运用户,山东5A景区喊你免费游园啦!
- Make it more automatic to transfer slow logs and audit logs of RDS (for MySQL) databases to OBS across spaces
- 阿里云过户找不到账号安全组ID问题
- 让RDS(for MySQL)数据库的慢日志、审计日志跨空间转存OBS变得更加自动化
猜你喜欢

"Half of Zhejiang's Venture Capital Circle" must be state-owned assets

Q: how bad can a programmer be?

Unity中通过射线躲避障碍物寻路的一些初步探索

Game NFT Market: opensea's most easily cut cake

2022年G2电站锅炉司炉题库及在线模拟考试
![[win11] right click fix to modify the registry but not create a new one](/img/5c/1ce29da6f1325f9f6c84984ae0c2e5.png)
[win11] right click fix to modify the registry but not create a new one
Golang实现基于Redis的可靠延迟队列

@“齐鲁多娇”幸运用户,山东5A景区喊你免费游园啦!

Nuxt - Universal (SSR / SSG) / single page app (rendering mode)

c# sqlsugar,hisql,freesql orm框架全方位性能测试对比之sqlserver
随机推荐
In May, 2022, China's game manufacturers and applications went to sea, with top 30 revenue in EMEA region
Some preliminary explorations of avoiding obstacles and finding paths by rays in unity
数组模拟栈
What is flush software? Is it safe to open an account online?
[learn shell programming easily]-4. The difference between single quotation marks and double quotation marks, the operation of integer values, the definition of arrays in the shell and the detailed us
RF analyzer demo setup
传统图像--LBP特征
Jenkins configuration project integration pin notification
Preliminary controller input of oculus learning notes (1)
问下 cdc 2.2.1监控sqlServer是不支持监控多库的吗?
Array implementation of circular linked list
写一本畅销书是怎样的一种体验
Make it more automatic to transfer slow logs and audit logs of RDS (for MySQL) databases to OBS across spaces
2022年5月中国游戏厂商及应用出海 EMEA 地区收入30强
Redis usage scenario sharing (project practice)
d的dip1000,1
炒股开户选择哪个券商公司是最安全最好呢
RF Analyzer Demo搭建
Conda——基础配置命令总结
Which securities company is better to open an account when making an appointment to play new bonds? It is safer to open an account