当前位置:网站首页>12. Double pointer -- merge two ordered linked lists
12. Double pointer -- merge two ordered linked lists
2022-07-28 10:16:00 【[email protected]】
- Input :1->2->4, 1->3->4
Output :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://yzsam.com/2022/209/202207280958224161.html
边栏推荐
- 02.1.2.逻辑类型 bool
- Flink - checkpoint Failure reason: Not all required tasks are currently running
- What are the highlights of B2B2C system? How to help jewelry enterprises build an omni channel multi merchant mall management system
- 传全球半导体设备巨头或将于上海建合资工厂!
- Prometheus operation and maintenance tool promtool (IV) TSDB function
- 指令系统超全知识点详解
- 2. 输出数组中重复的数字之一
- 多线程与高并发(三)—— 源码解析 AQS 原理
- 巧用ngx_lua做流量分组
- select如果不加order by子句,返回结果的顺序是不可靠的
猜你喜欢

ADVANCE.AI出海指南助力企业出海印尼,掌握东南亚市场半边天

7、二分法——寻找一组重复或者有序但是旋转的数组

Voice chat app - how to standardize the development process?
JWT login authentication + token automatic renewal scheme, well written!

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
![[openharmony] [rk2206] build openharmony compiler (2)](/img/0c/2e8290403d64ec43d192969f776724.png)
[openharmony] [rk2206] build openharmony compiler (2)

Why should I take the first-class constructor examination? How high is the gold content of the first-class Constructor Certificate?

Guangzhou metro line 14 xinshixu station is under construction, and residents in Baiyun District are about to start a double line transfer mode!

MySQL架构原理

【JZOF】14剪绳子
随机推荐
死锁算法:银行家算法和安全性算法
13、哈希表——两个链表第一个公共节点
LinkedList源码按摩,啊舒服
10 minute quick start EVs [play Huawei cloud]
leetcode076——数组中的第 k 大的数字
Etcd(高可用KV数据库)
Prometheus 运维工具 Promtool (四)TSDB 功能
Redis设计规范
管道、管程、管态的区别
LIBCMTD.lib
上下文变量值(context values)陷阱及在 Go 中如何避免或缓和这些陷阱
Step 4 - user development environment settings
select如果不加order by子句,返回结果的顺序是不可靠的
UEditor V1.4.3控制文件压缩
Etcd (highly available kV database)
Lucene 查询语法备忘
ADVANCE.AI出海指南助力企业出海印尼,掌握东南亚市场半边天
按位与、或、异或等运算方法
Performance test of API gateway APIs IX in Google cloud T2a and T2D
Thinking and summary of technical personnel | R & D Efficiency