码迷,mamicode.com
首页 > 其他好文 > 详细

Merge Two Sorted Lists

时间:2015-01-29 17:44:28      阅读:116      评论:0      收藏:0      [点我收藏+]

标签:

题目:

Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.

我的解法:

(1)算法思想:

先根据两个链表l1,l2头结点值的大小设置要返回链表的头结点head,然后依次交叉遍历l1,l2,将结点的较小值插入到head之后。

(2)代码如下:


Merge Two Sorted Lists

标签:

原文地址:http://blog.csdn.net/littlebob180/article/details/43272647

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!