当前位置:网站首页>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边栏推荐
- How does flynk MySQL CDC guarantee the server_ Is the ID globally unique?
- [OWT] OWT client native P2P E2E test vs2017 build
- Heartless sword in Chinese
- 怎么才能自动预约打新债?预约打新债方便安全吗
- Array implementation of circular linked list
- I became a big enemy when I bought wanghong ice cream
- High voltage direct current (HVDC) model based on converter (MMC) technology and voltage source converter (VSC) (implemented by MATLAB & Simulink)
- 大一女生废话编程爆火!懂不懂编程的看完都拴Q了
- 如何持续突破性能表现? | DX研发模式
- SystemVerilog (12) - $unit declaration space
猜你喜欢

At 19:30 today, the science popularization leader said that he would take you to explore how AI can stimulate human creativity
![[applet project development -- Jingdong Mall] configuration tabbar & window style for uni app development](/img/cd/bdf26a02a43c63f374861e8431787c.png)
[applet project development -- Jingdong Mall] configuration tabbar & window style for uni app development

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

Activity启动流程梳理

Correct method of converting Inkscape into DXF file SVG exporting DXF file

链表4- 21 合并两个有序链表

项目经理们在哪个时刻特别想逃离工作?

What is the experience of writing a best seller

I became a big enemy when I bought wanghong ice cream

详解openGauss多线程架构启动过程
随机推荐
自定义数据库连接池类: 要求:封闭一个Collection对象的集合类
Live streaming: dongyuhui is so popular. Is there anyone watching liuzhenhong?
Complete the sqlsession interface and implementation classes
When do project managers particularly want to escape from work?
中国移动手机用户缓慢增长,但努力争取高利润的5G套餐用户
Sort---
docker: Error response from daemon: Conflict. The container name “/mysql“ is already in use by conta
写一本畅销书是怎样的一种体验
[tools] related use of PIP and CONDA
The world's first AR contact lens, the entrance of metauniverse is really opened this time?
Nuxt - 超详细环境搭建及创建项目整体流程(create-nuxt-app)
新东方转型双语直播带货给项目管理人的一场课
The Fourth Youth Life Science Forum | first round notice
In May, 2022, China's game manufacturers and applications went to sea, with top 30 revenue in EMEA region
Mysql如何删除数据库表中的某一列
JVM快速入门
What happened to this page when sqlserver was saving
List的同步类比较
网络智能运维助力运维效率提升
第四届青年生命科学论坛 | 第一轮通知