当前位置:网站首页>Leetcode 21. merge two ordered linked lists
Leetcode 21. merge two ordered linked lists
2022-07-22 20:12:00 【henujolly】
class Solution {
public ListNode mergeTwoLists(ListNode l1, ListNode l2) {
ListNode res = new ListNode();
ListNode current = res;
while(l1 != null && l2 != null) {
if(l1.val < l2.val) {
current.next = l1;
l1 = l1.next;
}else {
current.next = l2;
l2 = l2.next;
}
current = current.next;
}
if(l1 != null) {
current.next = l1;
}else {
current.next = l2;
}
return res.next;
}
}
边栏推荐
- Kotlin学习三:集合与Lambda
- Customization of development mode of NFT mining Dividend System
- 【闲谈】工作两年随笔
- The difference between location.replace and location.href
- vmware nat模式下主机ping不通虚拟机:跟大部分方法不一样
- Spark Jason log analysis
- 求幂的位数,求阶乘的位数
- Kotlin learning 1: variables, functions, conditional statements and loop statements
- Elastic Search 学习入门之生产环境下node.master和node.data的设置(三)
- Flutter 2进阶(六):回调函数的使用
猜你喜欢
PyTorch学习——利用梯度下降法实现一元线性回归
Altium一键自动出BOM
Xilinx FPGA Microblaze AXI_IIC使用方法及心得
【C】从内存出发理解C语言变量作用域与生命周期
Matlab FFT参数设置研究
appstore 上传屏幕快照尺寸
Opening soon | openatom openharmony sub forum of 2022 open atom global open source summit "interconnection of all things, enabling thousands of industries"
CNN的简单实现过程
如何将Word转化为Markdown文本
HDU5667 Sequence
随机推荐
Elastic Search 学习入门之中文检索(八)
求N!后面有多少个0
Five levels of people and products
Elastic Search 学习入门之Search全文检索(七)
蓝桥杯省赛训练营——日期的计算
pyplot. When using plot: userwarning: starting a Matplotlib GUI outside of the main thread will like fail
NC4 判断链表中是否有环
leetcode 394. 字符串解码
数据开发常用工具---查询结果邮件定时发送
Matlab FFT参数设置研究
【校招总结】【旧文回顾】百度实习收获美团网易小米华为远景offer
Shutter 2 Advanced (II): shutter air safety
Elastic Search 学习入门之restful的高级查询操作(九)
RRPN:Arbitrary-Oriented Scene Text Detection via Rotation Proposals
Elastic Search 学习入门之插件安装(五)
pyplot.plot使用遇到:UserWarning: Starting a Matplotlib GUI outside of the main thread will likely fail
When the appsstore transporter uploads, it is stuck in the process of verifying the problem
转载:缓存一致性(Cache Coherency)入门
Installation of mysql5.7 (yum, binary, compile and install)
Development and construction of NFT card chain game system DAPP