当前位置:网站首页>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
边栏推荐
- Is it safe to open a securities account? Is there any danger
- ArrayList扩容详解
- MySQL connection tools
- Detailed explanation of ArrayList expansion
- 关于企业中台规划和 IT 架构微服务转型
- Depth first search - DFS (burst search)
- MES production equipment manufacturing execution system software
- Blue Bridge Cup real topic: the shortest circuit
- How to learn automated testing?
- From comedians to NBA Zhan Huang, check the encrypted advertisements during this super bowl
猜你喜欢

Mujoco model learning record

Data query language (DQL)

t10_ Adapting to Market Participantsand Conditions

Check log4j problems using stain analysis

Xia CaoJun ffmpeg 4.3 audio and video foundation to engineering application

Leetcode 1380. Lucky numbers in the matrix (save the minimum number of each row and the maximum number of each column)

必看,时间序列分析

Force buckle day33

Highly reliable program storage and startup control system based on anti fuse FPGA and QSPI flash
![[source code analysis] NVIDIA hugectr, GPU version parameter server - (1)](/img/92/f3a70e7086aeedf41eea3eef98b5aa.jpg)
[source code analysis] NVIDIA hugectr, GPU version parameter server - (1)
随机推荐
From comedians to NBA Zhan Huang, check the encrypted advertisements during this super bowl
Three.js学习-相机Camera的基本操作(了解向)
Bernoulli distribution (a discrete distribution)
PTA year of birth
2、《创建您自己的NFT集合并发布一个Web3应用程序来展示它们》启动并运行您的本地环境
Thread forced join, thread forced join application scenarios
证券开户安全么,有没有什么样的危险呢
Develop those things: add playback address authentication to easycvr platform
Set the style of QT property sheet control
D @ safety and dip1000
Localization through custom services in the shuttle application
Operation of cmake under win
Calculation of intersection of two line segments
MySQL connection tools
Quick foundation of group theory (5): generators, Kelley graphs, orbits, cyclic graphs, and "dimensions" of groups?
Is it safe to open a securities account? Is there any danger
Oracle TRUNC function processing date format
Redis master-slave realizes 10 second check and recovery
(6) VIM editor MV cat redirection standard input and output more pipe symbols head tail
1、《创建您自己的NFT集合并发布一个Web3应用程序来展示它们》什么是NFT