当前位置:网站首页>LeetCode-21合并两个有序链表
LeetCode-21合并两个有序链表
2022-07-01 18:33:00 【原来是大海】
# Definition for singly-linked list.
# class ListNode(object):
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next
class Solution(object):
def mergeTwoLists(self, list1, list2):
"""
:type list1: Optional[ListNode]
:type list2: Optional[ListNode]
:rtype: Optional[ListNode]
"""
chushihua = ListNode(0)
new = chushihua
while list1 and list2:
if list1.val <= list2.val:
new.next =list1
list1 = list1.next
else:
new.next = list2
list2 = list2.next
new = new.next
new.next = list1 if list1 is not None else list2
return chushihua.next
边栏推荐
- Mysql database design
- APK签名流程介绍[通俗易懂]
- Zabbix报警执行远程命令
- (6) VIM editor MV cat redirection standard input and output more pipe symbols head tail
- 证券开户安全么,有没有什么样的危险呢
- 3、《创建您自己的NFT集合并发布一个Web3应用程序来展示它们》在本地铸造 NFT
- . Net cloud native architect training camp (permission system code implements actionaccess) -- learning notes
- [source code analysis] model parallel distributed training Megatron (5) -- pipestream flush
- 必看,时间序列分析
- Win10+vs2019 Community Edition compiling OpenSSL
猜你喜欢
Record 3 - the state machine realizes key control and measures the number of external pulses
C# SelfHost WebAPI (2)
Relational database management system of easyclick
Domestic spot silver should be understood
How to retrieve the password for opening Excel files
Quick foundation of group theory (5): generators, Kelley graphs, orbits, cyclic graphs, and "dimensions" of groups?
Leetcode-128 最长连续序列
2、《创建您自己的NFT集合并发布一个Web3应用程序来展示它们》启动并运行您的本地环境
Nearly 60% of the employees strongly support Ctrip's "3+2" working mode, and work at home for two days a week
3、《创建您自己的NFT集合并发布一个Web3应用程序来展示它们》在本地铸造 NFT
随机推荐
Highly reliable program storage and startup control system based on anti fuse FPGA and QSPI flash
APK签名流程介绍[通俗易懂]
Android development interview was badly hit in 3 years, and now the recruitment technical requirements are so high?
PTA year of birth
Sum of three numbers
Static timing analysis (STA) in ic/fpga design
Implementation of converting PCM file to WAV
What is web application security testing technology?
EasyCVR设备录像出现无法播放现象的问题修复
The ultimate version of the 13th simulation of the single chip microcomputer provincial competition of the Blue Bridge Cup
What impact will multinational encryption regulation bring to the market in 2022
Session layer of csframework, server and client (1)
3、《创建您自己的NFT集合并发布一个Web3应用程序来展示它们》在本地铸造 NFT
The method of real-time tracking the current price of London Silver
Yuancosmos game farmersworld farmers world - core content of the second conference in China!
Win10+vs2019 Community Edition compiling OpenSSL
Computer network interview assault
How to retrieve the password for opening Excel files
[Chongqing Guangdong education] basic psychology reference materials of Tianjin Normal University
Is online stock account opening safe? Is it reliable?