Skip to content

Latest commit

 

History

History
40 lines (29 loc) · 1.02 KB

0023-merge-k-sorted-lists.adoc

File metadata and controls

40 lines (29 loc) · 1.02 KB

23. Merge k Sorted Lists

{leetcode}/problems/merge-k-sorted-lists/[LeetCode - Merge k Sorted Lists^]

Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.

Example:

Input:
[
  1->4->5,
  1->3->4,
  2->6
]
Output: 1->1->2->3->4->4->5->6

思路分析

优先队列是最优解,退而求其次,可以考虑使用分治。

link:{sourcedir}/_0023_MergeKSortedLists.java[role=include]
link:{sourcedir}/_0023_MergeKSortedLists_2.java[role=include]