Skip to content

Latest commit

 

History

History
82 lines (58 loc) · 2.15 KB

0021-merge-two-sorted-lists.adoc

File metadata and controls

82 lines (58 loc) · 2.15 KB

21. Merge Two Sorted Lists

{leetcode}/problems/merge-two-sorted-lists/[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 together the nodes of the first two lists.

{image_attr}

Example:

Input: 1->2->4, 1->3->4
Output: 1->1->2->3->4->4

思路分析

最先想到的是迭代。

但是,也可以用递归解决!

{image_attr}
{image_attr}
{image_attr}
{image_attr}
{image_attr}
{image_attr}
{image_attr}
{image_attr}
{image_attr}
{image_attr}
一刷
link:{sourcedir}/_0021_MergeTwoSortedLists.java[role=include]
二刷
link:{sourcedir}/_0021_MergeTwoSortedLists_2.java[role=include]
三刷
link:{sourcedir}/_0021_MergeTwoSortedLists_3.java[role=include]