这是一道hard的题目,在此之前,先看与之类似的easy的题目:
LeetCode#21 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.
Example:1
2Input: 1->2->4, 1->3->4
Output: 1->1->2->3->4->4
合并两个已排序的链表,非常简单,分别从头开始遍历,并对比,将小的数添加到前面即可。如下: