当前位置:网站首页>Leetcode-21 combines two ordered linked lists
Leetcode-21 combines two ordered linked lists
2022-07-01 18:47:00 【It was the sea】

# 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
边栏推荐
- 12. Design of power divider for ads usage record
- Write it down once Net travel management background CPU Explosion Analysis
- Why do independent website sellers start to do social media marketing? The original customer conversion rate can be improved so much!
- 创建您自己的NFT集合并发布一个Web3应用程序来展示它们(介绍)
- 力扣每日一题-第32天-1232. 缀点成线
- 斯坦福、Salesforce|MaskViT:蒙面视觉预训练用于视频预测
- R语言ggplot2可视化:gganimate创建动态柱状图动画(gif)、在动画中沿给定维度逐步显示柱状图、enter_grow函数和enter_fade函数控制运动内插退出(渐变tweening)
- Vue uses keep alive to cache page optimization projects
- 隐私沙盒终于要来了
- How to manage 1000 anchors by one person?
猜你喜欢

t10_ Adapting to Market Participantsand Conditions

Leetcode-141环形链表

After studying 11 kinds of real-time chat software, I found that they all have these functions

Salesmartly has some tricks for Facebook chat!

Navicat premium 15 permanent cracking and 2021 latest idea cracking (valid for personal testing)

Search 2D matrix 2

AI 训练速度突破摩尔定律;宋舒然团队获得RSS 2022最佳论文奖

宏观视角看抖音全生态

Halcon图片标定,使得后续图片处理过后变成与模板图片一样

Lumiprobe bifunctional crosslinker sulfo cyanine 5 bis NHS ester
随机推荐
R语言ggplot2可视化:gganimate包transition_time函数创建动态散点图动画(gif)、shadow_wake函数配置动画的渐变效果(gradual falloff)拖尾效应
每周推荐短视频:警惕“现象”与“问题”相互混淆
Leetcode-160相交链表
[CF559E]Gerald and Path
隐私沙盒终于要来了
搭建一個通用監控告警平臺,架構上需要有哪些設計
Lumiprobe non fluorescent alkyne EU (5-ethynyluridine)
LeetCode-21合并两个有序链表
Bernoulli distribution (a discrete distribution)
(6) VIM editor MV cat redirection standard input and output more pipe symbols head tail
创建您自己的NFT集合并发布一个Web3应用程序来展示它们(介绍)
What if the reliability coefficient is low? How to calculate the reliability coefficient?
About enterprise middle office planning and it architecture microservice transformation
Evaluation of 6 red, yellow and black list cameras: who is the safest? Who has good picture quality? From now on, let you no longer step on thunder
On the language internationalization of Yongzhong Office
The 13th simulation problem of the single chip microcomputer provincial competition of the Blue Bridge Cup
磁盘的基本知识和基本命令
540. Single element in ordered array
Reading notes series "modern methods of C language programming" -- Chapter 2
Five degrees easy chain enterprise app is newly upgraded