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 ...
随机推荐
- Interpolation particles In Katana
I write the sphere radius interpolation for katana plugin that can transfer attributes,render attrib ...
- 数据结构 B-树和B+树的应用:数据搜索和数据库索引
B-树 1 .B-树定义 B-树是一种平衡的多路查找树,它在文件系统中很有用. 定义:一棵m 阶的B-树,或者为空树,或为满足下列特性的m 叉树:⑴树中每个结点至多有m 棵子树:⑵若根结点不是叶子结点 ...
- Thinkphp学习回顾(一)之基本结构目录
TP框架的学习一般都是从了解框架的基本结构开始的,每个文件都有其专属的作用,我的TP框架的回顾也从基本结构开始讲起. 一.ThinkPHP的获取 http://www.thinkphp.cn 这是 ...
- easyui validatebox 验证类型
required: "必选字段", remote: "请修正该字段", email: "请输入正确格式的电子邮件" ...
- 20161014001 DataGridView 单元格内容 自动计算
private void T_Form_CY_CBD_D_CellValueChanged(object sender, DataGridViewCellEventArgs e) { ...
- Javascript:谈谈JS的全局变量跟局部变量
原文链接:http://blog.csdn.net/zyz511919766/article/details/7276089# 今天公司一个实习小妹子问我两段JS代码的区别: <script t ...
- AutoMagic
AutoMagic 是一个基于WebUI的自动化管理平台.为什么叫AutoMagic呢?因为自动化(Automation)在执行起来的时候是一个很神奇的事情,它可以无人值守的模拟人的操作,就像魔术(M ...
- Fragment全解析系列(二):正确的使用姿势
作为一个稳定的app,从后台且回到前台,一定会在任何情况都能恢复到离开前的页面,并且保证数据的完整性. 如果你没看过本系列的第一篇,为了方便后面文章的介绍,先规定一个"术语",安卓 ...
- 【RabbitMQ】RabbitMQ的一些基础概念
工作中使用的是RabbitMQ,需要对其进行熟悉.使用之前,弄清楚它是什么东西,解决什么问题. 场景 一些不必实时执行的任务 开发中,有一些任务并无须实时执行,比如: 会员更新个人信息,更新会员信息之 ...
- 闲的写写SQL
/* 新增 */ Create Proc AddData ( ), ), @Values nvarchar(max) ) as declare @Sql nvarchar(max) declare @ ...