Leetcode--Merge Two Sorted Lists
static ListNode *mergeTwoLists(ListNode *l1, ListNode *l2) {
ListNode *temp = );
ListNode *head = temp;
if (l1 == NULL && l2 == NULL)
return head;
while (l1 != NULL && l2 != NULL) {
if (l1->val <= l2->val) {
temp->next = new ListNode(l1->val);
temp = temp->next;
l1 = l1->next;
} else {
temp->next = new ListNode(l2->val);
temp = temp->next;
l2 = l2->next;
}
}
if (l1 == NULL && l2 != NULL)
temp->next = l2;
else if (l2 == NULL && l1 != NULL)
temp->next = l1;
return head->next;
}
Leetcode--Merge Two Sorted Lists的更多相关文章
- [LeetCode] Merge k Sorted Lists 合并k个有序链表
Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. 这 ...
- [LeetCode] Merge Two Sorted Lists 混合插入有序链表
Merge two sorted linked lists and return it as a new list. The new list should be made by splicing t ...
- LeetCode: Merge Two Sorted Lists 解题报告
Merge Two Sorted Lists Merge two sorted linked lists and return it as a new list. The new list shoul ...
- LeetCode: Merge k Sorted Lists 解题报告
Merge k Sorted Lists Merge k sorted linked lists and return it as one sorted list. Analyze and descr ...
- [Leetcode] Merge k sorted lists 合并k个已排序的链表
Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. 思 ...
- LeetCode:Merge k Sorted Lists
题目链接 Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexi ...
- LeetCode——Merge k Sorted Lists
Discription: Merge k sorted linked lists and return it as one sorted list. Analyze and describe its ...
- leetcode:Merge Two Sorted Lists(有序链表的归并)
Merge two sorted linked lists and return it as a new list. The new list should be made by splicing t ...
- leetcode -- Merge k Sorted Lists add code
Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. [ ...
- LeetCode Merge k Sorted Lists (链表)
题意 Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity ...
随机推荐
- 学习笔记:MySQL数据库初步 概念
数据库 什么是数据库,数据库就是对大量信息进行管理的高效的解决方案,按照数据结构来组织.存储和管理数据的载体.而我们常说的数据库可以分为关系型和非关系型数据库. 关系型数据库 这里说的关系型数据库,是 ...
- Tween.js的使用示例
可参考:http://www.htmleaf.com/jQuery/Layout-Interface/201501271284.html 官方文档:https://github.com/tweenjs ...
- Countries in War -POJ3114Tarjan缩点+SPFA
Countries in War Time Limit: 1000MS Memory Limit: 65536K Description In the year 2050, after differe ...
- sql的各种join连接
SELECT * FROM TableA INNER JOIN TableB ON TableA.name = TableB.name id name id name -- ---- -- ---- ...
- 个人项目制作(PSP)
计划: 软件的此功能的实现,个人估算需要一个周的时间. 开发阶段: 需求分析: 1> 运动员希望软件可以记录自己的得分项. 2> 运动员希望软件可以记录自己的得分具体细节. 3>运动 ...
- finish()在dialog中的作用
finish()在dialog中销毁的是dialog所在的活动:
- UVALive 3635 分派
https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_probl ...
- IE11 HTML Help ActiveX
<!--by: @qab--> <OBJECT id=HHCTRL type="application/x-oleobject" classid="cl ...
- T-SQL编程 —— 用户自定义函数(内嵌表值函数)
内嵌表值函数 接上 <T-SQL编程 -- 用户自定义函数(标量函数)> http://www.cnblogs.com/viusuangio/p/6212072.html 内嵌表值函数可以 ...
- Java(JCo3)与SAP系统相互调用
声明:原创作品,转载时请注明文章来自SAP师太技术博客( 博/客/园www.cnblogs.com):www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将 ...