|
| 1 | +<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> |
| 2 | + |
| 3 | +<p><em>Merge all the linked-lists into one sorted linked-list and return it.</em></p> |
| 4 | + |
| 5 | +<p> </p> |
| 6 | +<p><strong>Example 1:</strong></p> |
| 7 | + |
| 8 | +<pre><strong>Input:</strong> lists = [[1,4,5],[1,3,4],[2,6]] |
| 9 | +<strong>Output:</strong> [1,1,2,3,4,4,5,6] |
| 10 | +<strong>Explanation:</strong> The linked-lists are: |
| 11 | +[ |
| 12 | + 1->4->5, |
| 13 | + 1->3->4, |
| 14 | + 2->6 |
| 15 | +] |
| 16 | +merging them into one sorted list: |
| 17 | +1->1->2->3->4->4->5->6 |
| 18 | +</pre> |
| 19 | + |
| 20 | +<p><strong>Example 2:</strong></p> |
| 21 | + |
| 22 | +<pre><strong>Input:</strong> lists = [] |
| 23 | +<strong>Output:</strong> [] |
| 24 | +</pre> |
| 25 | + |
| 26 | +<p><strong>Example 3:</strong></p> |
| 27 | + |
| 28 | +<pre><strong>Input:</strong> lists = [[]] |
| 29 | +<strong>Output:</strong> [] |
| 30 | +</pre> |
| 31 | + |
| 32 | +<p> </p> |
| 33 | +<p><strong>Constraints:</strong></p> |
| 34 | + |
| 35 | +<ul> |
| 36 | + <li><code>k == lists.length</code></li> |
| 37 | + <li><code>0 <= k <= 10<sup>4</sup></code></li> |
| 38 | + <li><code>0 <= lists[i].length <= 500</code></li> |
| 39 | + <li><code>-10<sup>4</sup> <= lists[i][j] <= 10<sup>4</sup></code></li> |
| 40 | + <li><code>lists[i]</code> is sorted in <strong>ascending order</strong>.</li> |
| 41 | + <li>The sum of <code>lists[i].length</code> will not exceed <code>10<sup>4</sup></code>.</li> |
| 42 | +</ul> |
| 43 | +</div> |
0 commit comments