首页 > 代码库 > Merge Two Sorted Lists

Merge Two Sorted Lists

题目:

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)代码如下:

<script src="https://code.csdn.net/snippets/592652.js" type="text/javascript"></script>

Merge Two Sorted Lists