Merge Two Sorted List

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.

这题用递归做最简单。 【我是怎么想到用递归的? 因为学校作业有过~】

思路: 

List A : 1-->3-->5-->7-->9   排序好了

List B   2-->4-->6-->8-->10  排序好了

从两个list里挑最小的那个,肯定是第一个。 第二个的话就是大一点的那个完整的list 和 另一个list来重复之前的操作。

Merge Two Sorted List_第1张图片

你可能感兴趣的:(Merge Two Sorted List)