1. You are given K sorted (increasing order) linked lists. 2. You have to write a function that merges them in such a way that the resulting list is in increasing order. 3. display is a utility function which displays the contents of Linked List, feel free to use it for debugging purposes. 4. main takes input from the users and creates the Linked Lists. You can use display to know its contents. 5. This is a functional problem. 6. You have to complete the mergeKList function. It takes as input an array of heads of K linked lists. It also takes as input the length of the array. It should return the head of the merged list. 7. Don't change the code of Node, main and display.
Input Format
First line takes input K, the number of sorted linked lists. First line of next K pair of lines takes input N that denotes the number of elements of linked list. Next line takes input N space separated numbers reperesenting elements of the linked list. Input is handled for you.
Output Format
Merged linked list Output is handled for you.
Constraints
1 <= K <= 50 1 <= N <= 100
Notice
Try First, Check Solution later
1. You should first read the question and watch the question video.2. Think of a solution approach, then try and submit the question on editor tab.3. We strongly advise you to watch the solution video for prescribed approach.Example
Input
2 3 10 20 30 4 5 15 25 30
Output
5 10 15 20 25 30 30