当前位置:网站首页>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
边栏推荐
- The method of real-time tracking the current price of London Silver
- Apk signature process introduction [easy to understand]
- MySQL connection tools
- Zabbix报警执行远程命令
- 关于企业中台规划和 IT 架构微服务转型
- 因子分析怎么计算权重?
- Distributed task queue: Celery usage record
- Draw drawing process of UI drawing process
- A wonderful time to buy and sell stocks
- Rust language - cargo, crates io
猜你喜欢

The 13th simulation problem of the single chip microcomputer provincial competition of the Blue Bridge Cup

Extract the compressed package file and retrieve the password

Bernoulli distribution (a discrete distribution)

1、《创建您自己的NFT集合并发布一个Web3应用程序来展示它们》什么是NFT

信度系数低怎么办?信度系数具体怎么算?

Unity learning fourth week
![[image denoising] matlab code for removing salt and pepper noise based on fast and effective multistage selective convolution filter](/img/bf/f8759195ea67832835e84c851b5e81.jpg)
[image denoising] matlab code for removing salt and pepper noise based on fast and effective multistage selective convolution filter

GAMES202作业0-环境搭建过程&解决遇到的问题

A database editing gadget that can edit SQLite database. SQLite database replaces fields. SQL replaces all values of a field in the database

Highly reliable program storage and startup control system based on anti fuse FPGA and QSPI flash
随机推荐
Android development interview was badly hit in 3 years, and now the recruitment technical requirements are so high?
Depth first search - DFS (burst search)
Introduction to easyclick database
golang中的select详解
Draw drawing process of UI drawing process
Nielseniq found that 60% of the re launched products had poor returns
Basic usage of shell script
2、《创建您自己的NFT集合并发布一个Web3应用程序来展示它们》启动并运行您的本地环境
L'ouverture d'un compte d'actions en ligne est - elle sécurisée? Fiable?
ZABBIX alarm execute remote command
Fix the black screen caused by iPhone system failure
Equipment simulation and deduction training system software
传感器尺寸、像素、DPI分辨率、英寸、毫米的关系
Sanfeng cloud 0215 I often use
(6) VIM editor MV cat redirection standard input and output more pipe symbols head tail
Financial judgment questions
每周推荐短视频:警惕“现象”与“问题”相互混淆
期货账户的资金安全吗?怎么开户?
Session layer of csframework, server and client (1)
ArrayList扩容详解