-
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
1 parent
920c8ff
commit 3fed1b4
Showing
1 changed file
with
20 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,20 @@ | ||
<h2><a href="https://www.geeksforgeeks.org/problems/merge-k-sorted-linked-lists/1">Merge K sorted linked lists</a></h2><h3>Difficulty Level : Difficulty: Medium</h3><hr><div class="problems_problem_content__Xm_eO"><p><span style="font-size: 18px;">Given an array <strong>arr[] </strong>of <strong>n</strong> <strong>sorted linked lists</strong> of different sizes. The task is to <strong>merge</strong> them in such a way that after merging they will be a <strong>single sorted</strong> linked list, then <strong>return </strong>the<strong> head</strong> of the merged linked list.</span></p> | ||
<p><span style="font-size: 18px;"><strong>Examples:</strong></span></p> | ||
<pre><span style="font-size: 18px;"><strong>Input: </strong>arr[] = [1 -> 2 -> 3, 4 -> 5, 5 -> 6, 7 -> 8] | ||
<strong>Output: </strong>1 -> 2 -> 3 -> 4 -> 5 -> 5 -> 6 -> 7 -> 8<strong> | ||
Explanation:<br></strong>The arr[] has 4 sorted linked list of size 3, 2, 2, 2. | ||
1st list: 1 -> 2-> 3 | ||
2nd list: 4 -> 5 | ||
3rd list: 5 -> 6 | ||
4th list: 7 -> 8 | ||
The merged list will be: | ||
</span><img src="https://media.geeksforgeeks.org/img-practice/prod/addEditProblem/700265/Web/Other/blobid0_1737094930.png" width="388" height="68"> </pre> | ||
<pre><span style="font-size: 18px;"><strong>Input: </strong>arr[] = [1 -> 3, 8, 4 -> 5 -> 6] | ||
<strong>Output: </strong>1 -> 3 -> 4 -> 5 -> 6 -> 8<strong> | ||
Explanation:<br></strong>The arr[] has 3 sorted linked list of size 2, 3, 1. | ||
1st list: 1 -> 3 | ||
2nd list: 8 | ||
3rd list: 4 -> 5 -> 6 | ||
The merged list will be:<br><img src="https://media.geeksforgeeks.org/img-practice/prod/addEditProblem/700265/Web/Other/blobid1_1722513386.png" width="400" height="70"></span> | ||
</pre> | ||
<p><span style="font-size: 18px;"><strong>Constraints</strong><br>1 <= total no. of nodes <= 10<sup>5</sup><sup><br></sup>1 <= node->data <= 10<sup>3</sup></span></p></div><p><span style=font-size:18px><strong>Company Tags : </strong><br><code>VMWare</code> <code>Amazon</code> <code>Microsoft</code> <code>Oracle</code> <br><p><span style=font-size:18px><strong>Topic Tags : </strong><br><code>Linked List</code> <code>Heap</code> <code>Data Structures</code> |