-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<h2><a href="https://leetcode.com/problems/merge-k-sorted-lists/">23. Merge k Sorted Lists</a></h2><h3>Hard</h3><hr><div><p>You are given an array of <code>k</code> linked-lists <code>lists</code>, each linked-list is sorted in ascending order.</p> | ||
|
||
<p><em>Merge all the linked-lists into one sorted linked-list and return it.</em></p> | ||
|
||
<p> </p> | ||
<p><strong>Example 1:</strong></p> | ||
|
||
<pre><strong>Input:</strong> lists = [[1,4,5],[1,3,4],[2,6]] | ||
<strong>Output:</strong> [1,1,2,3,4,4,5,6] | ||
<strong>Explanation:</strong> The linked-lists are: | ||
[ | ||
1->4->5, | ||
1->3->4, | ||
2->6 | ||
] | ||
merging them into one sorted list: | ||
1->1->2->3->4->4->5->6 | ||
</pre> | ||
|
||
<p><strong>Example 2:</strong></p> | ||
|
||
<pre><strong>Input:</strong> lists = [] | ||
<strong>Output:</strong> [] | ||
</pre> | ||
|
||
<p><strong>Example 3:</strong></p> | ||
|
||
<pre><strong>Input:</strong> lists = [[]] | ||
<strong>Output:</strong> [] | ||
</pre> | ||
|
||
<p> </p> | ||
<p><strong>Constraints:</strong></p> | ||
|
||
<ul> | ||
<li><code>k == lists.length</code></li> | ||
<li><code>0 <= k <= 10^4</code></li> | ||
<li><code>0 <= lists[i].length <= 500</code></li> | ||
<li><code>-10^4 <= lists[i][j] <= 10^4</code></li> | ||
<li><code>lists[i]</code> is sorted in <strong>ascending order</strong>.</li> | ||
<li>The sum of <code>lists[i].length</code> won't exceed <code>10^4</code>.</li> | ||
</ul> | ||
</div> |