当前位置:网站首页>12、双指针——合并两个有序链表
12、双指针——合并两个有序链表
2022-07-28 09:58:00 【[email protected]】
- 输入:1->2->4, 1->3->4
输出:1->1->2->3->4->4
public ListNode mergeTwoLists(ListNode l1, ListNode l2) {
ListNode dum = new ListNode(0), cur = dum;
while(l1 != null && l2 != null){
if(l1.val < l2.val){
cur.next = l1;
l1 = l1.next;
}
else{
cur.next = l2;
l2 = l2.next;
}
cur = cur.next;
}
cur.next = l1 != null ? l1 : l2;
return dum.next;
}
版权声明
本文为[[email protected]]所创,转载请带上原文链接,感谢
https://blog.csdn.net/zjj1910066023/article/details/124778435
边栏推荐
- Basic examples that must be mastered by beginners of C #
- In hot weather, the line of defense for safe production was strengthened, and Guangzhou Haizhu District carried out emergency drills for gas stations
- matlab特征点提取--记录自用
- LinkedList source massage, ah comfortable
- [OpenHarmony] [RK2206] 构建OpenHarmony编译器 (二)
- 【JZOF】14剪绳子
- 医药行业数字化建设,箭在弦上
- 为什么要考一级建造师,一建证书含金量有多高?
- 博弈论 1.Introduction(组合游戏基本概念、对抗搜索、Bash游戏、Nim游戏)
- 21. 合并两个有序链表
猜你喜欢
![[OpenHarmony] [RK2206] 构建OpenHarmony编译器 (二)](/img/0c/2e8290403d64ec43d192969f776724.png)
[OpenHarmony] [RK2206] 构建OpenHarmony编译器 (二)
![[esp32][esp idf] esp32s3 quickly build lvglv7.9](/img/39/8efef047d0a9223b97819a54b5edf8.png)
[esp32][esp idf] esp32s3 quickly build lvglv7.9

定了!就在7月30日!

Arthas tutorial

Installing MySQL for Linux operating system (centos7)
![[ESP32][esp-idf] esp32s3快速搭建LVGLV7.9](/img/39/8efef047d0a9223b97819a54b5edf8.png)
[ESP32][esp-idf] esp32s3快速搭建LVGLV7.9

深度学习必懂的 13 种概率分布
![[jzof] 14 cut rope](/img/36/6f58b443a549ad245c1c4cfe5d13af.png)
[jzof] 14 cut rope

二分、三分、01分数规划【第III弹】

The blind box of super primitive series will be launched soon, and platofarm will enable more rights and interests
随机推荐
Sizebasedtriggingpolicy introduction
LinkedList源码按摩,啊舒服
ES(8.1)认证题目
Fixedwindowrollingpolicy introduction
Redis设计规范
剑指offer
SQL server, MySQL master-slave construction, EF core read-write separation code implementation
Why should I take the first-class constructor examination? How high is the gold content of the first-class Constructor Certificate?
️雄关漫道真如铁,而今迈步从头越️
Elk real time log analysis platform
我用小程序容器让移动研发效率提升了5倍!
ASP. Net core 6 framework unveiling example demonstration [29]: building a file server
Bit.store, which has attracted much attention, is at a glance of the latest developments
Data can't lie. Plato farm is the leader of the meta universe
Etcd(高可用KV数据库)
web之圣杯和双飞翼布局、float、clear、both
为报复公司解雇,我更改了项目的所有代码注释!
In retaliation for the dismissal of the company, I changed all code comments of the project!
Etcd (highly available kV database)
Consul