当前位置:网站首页>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
边栏推荐
猜你喜欢

为报复公司解雇,我更改了项目的所有代码注释!

Openatom openharmony sub forum, see you today at 14:00! Wonderful release of memorabilia attached

Thinking and summary of technical personnel | R & D Efficiency

图解 3 种主流企业架构模式(建议收藏!)

In hot weather, the line of defense for safe production was strengthened, and Guangzhou Haizhu District carried out emergency drills for gas stations

Flink - checkpoint Failure reason: Not all required tasks are currently running
JWT login authentication + token automatic renewal scheme, well written!

Skillfully use NGX_ Lua makes traffic grouping

ES(8.1)认证题目

What kind of knowledge payment system functions are more conducive to the development of the platform and lecturers?
随机推荐
Kubernetes
银行入职考试要点汇总
Description of landingsite electronic label quppa firmware entering DFU status
B2B e-commerce website scheme for building materials industry: enable the transformation and upgrading of building materials enterprises to achieve cost reduction and efficiency improvement
Consul
ES(8.1)认证题目
[ESP32][esp-idf] AP+STA实现无线桥接 中转wifi信号
LandingSite电子标签Quuppa固件进入DFU状态说明
uni-app进阶之生命周期
select如果不加order by子句,返回结果的顺序是不可靠的
博弈论 1.Introduction(组合游戏基本概念、对抗搜索、Bash游戏、Nim游戏)
2022-uni-app解析token标准的方式-使用jsrsasign-爬坑过了
(十)defer关键字
B2B2C系统亮点是什么?如何助力珠宝首饰企业打造全渠道多商户商城管理体系
In retaliation for the dismissal of the company, I changed all code comments of the project!
Cloudcompare & PCL matching point sampling consistency suppression
Tencent technical experts: decrypt the 100 million user products wechat, QQ, King glory... Comprehensively practice on the cloud!
ES (8.1) certification topic
LinkedList source massage, ah comfortable
软件设计师考前20问,注意啦!!