mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-06 07:51:41 +08:00
update
This commit is contained in:
45
leetcode/problem/merge-k-sorted-lists.html
Normal file
45
leetcode/problem/merge-k-sorted-lists.html
Normal file
@@ -0,0 +1,45 @@
|
||||
<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<sup>4</sup></code></li>
|
||||
<li><code>0 <= lists[i].length <= 500</code></li>
|
||||
<li><code>-10<sup>4</sup> <= lists[i][j] <= 10<sup>4</sup></code></li>
|
||||
<li><code>lists[i]</code> is sorted in <strong>ascending order</strong>.</li>
|
||||
<li>The sum of <code>lists[i].length</code> will not exceed <code>10<sup>4</sup></code>.</li>
|
||||
</ul>
|
Reference in New Issue
Block a user