当前位置:网站首页>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
边栏推荐
- 搭建一个通用监控告警平台,架构上需要有哪些设计
- How to change guns for 2D characters
- [source code analysis] NVIDIA hugectr, GPU version parameter server - (1)
- Lumiprobe非荧光炔烃丨EU(5-乙炔基尿苷)
- How to find customers for investment attraction in industrial parks
- [noip2015] jumping stone
- Mise en place d'une plate - forme générale de surveillance et d'alarme, quelles sont les conceptions nécessaires dans l'architecture?
- Lumiprobe bifunctional crosslinker sulfo cyanine 5 bis NHS ester
- Static timing analysis (STA) in ic/fpga design
- 力扣每日一题-第32天-1232. 缀点成线
猜你喜欢

Mise en place d'une plate - forme générale de surveillance et d'alarme, quelles sont les conceptions nécessaires dans l'architecture?

每周推荐短视频:警惕“现象”与“问题”相互混淆
![[source code analysis] NVIDIA hugectr, GPU version parameter server - (1)](/img/92/f3a70e7086aeedf41eea3eef98b5aa.jpg)
[source code analysis] NVIDIA hugectr, GPU version parameter server - (1)

Navicat Premium 15 永久破解和2021版本最新IDEA破解(亲测有效)

Leetcode-141环形链表

搭建一个通用监控告警平台,架构上需要有哪些设计

Cloud computing - make learning easier

Facebook聊单,SaleSmartly有妙招!

Static timing analysis (STA) in ic/fpga design

斯坦福、Salesforce|MaskViT:蒙面视觉预训练用于视频预测
随机推荐
R语言epiDisplay包ordinal.or.display函数获取有序logistic回归模型的汇总统计信息(变量对应的优势比及其置信区间、以及假设检验的p值)、write.csv函数保存csv
Computer network interview assault
1380. Lucky number in matrix / 1672 Total assets of the richest customers
How to operate technology related we media well?
Is the fund of futures account safe? How to open an account?
How to find customers for investment attraction in industrial parks
Weekly recommended short videos: be alert to the confusion between "phenomena" and "problems"
Blue Bridge Cup real problem: word analysis
Leetcode-128 最长连续序列
因子分析怎么计算权重?
What if the reliability coefficient is low? How to calculate the reliability coefficient?
PMP daily three questions (February 15, 2022)
Mise en place d'une plate - forme générale de surveillance et d'alarme, quelles sont les conceptions nécessaires dans l'architecture?
PTA year of birth
How does factor analysis calculate weights?
解决方案:可以ping别人,但是别人不能ping我
Find all missing numbers in the array
Regular expression
AI 训练速度突破摩尔定律;宋舒然团队获得RSS 2022最佳论文奖
A database editing gadget that can edit SQLite database. SQLite database replaces fields. SQL replaces all values of a field in the database