当前位置:网站首页>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
边栏推荐
- MFC obtains local IP (used more in network communication)
- Fix the black screen caused by iPhone system failure
- D. Yet Another Minimization Problem
- Mysql database of easyclick
- What is web application security testing technology?
- How to find the optimal learning rate
- Leetcode 1380. Lucky numbers in the matrix (save the minimum number of each row and the maximum number of each column)
- 2022 Heilongjiang latest fire protection facility operator simulation test question bank and answers
- C operator overloads the query table
- [source code analysis] NVIDIA hugectr, GPU version parameter server - (1)
猜你喜欢

Mysql database of easyclick

Xia CaoJun ffmpeg 4.3 audio and video foundation to engineering application

12种数据量纲化处理方式

Calculation of intersection of two line segments

因子分析怎么计算权重?

Relational database management system of easyclick

Samba basic usage

LeetCode 148. Sort linked list

t10_ Adapting to Market Participantsand Conditions

Basic concepts of binary tree
随机推荐
Growing up in the competition -- (Guangyou's most handsome cub) Pikachu walking
540. Single element in ordered array / 1684 Count the number of consistent strings
[today in history] February 15: Pascal's father was born; YouTube was founded; Kotlin language comes out
. Net cloud native architect training camp (permission system code implements actionaccess) -- learning notes
The method of real-time tracking the current price of London Silver
Sanfeng cloud 0215 I often use
Definition of rotation axis in mujoco
Blue Bridge Cup real topic: the shortest circuit
Localization through custom services in the shuttle application
网上股票开户安全吗?是否可靠?
540. Single element in ordered array
Leetcode problem solving series -- continuous positive sequence with sum as s (sliding window)
LeetCode 148. Sort linked list
信度系数低怎么办?信度系数具体怎么算?
Leetcode203 移除链表元素
Sum of three numbers
[source code analysis] NVIDIA hugectr, GPU version parameter server - (1)
From comedians to NBA Zhan Huang, check the encrypted advertisements during this super bowl
Convert the robot's URDF file to mujoco model
APK签名流程介绍[通俗易懂]