Loading problem...
You are provided with a collection of k linked lists, where each individual list is arranged in non-decreasing (ascending) order.
Your objective is to consolidate all these linked lists into a single, unified linked list that maintains the sorted order, and return the head of this resulting list.
Each input linked list contains nodes with integer values, and the goal is to interleave their elements such that the final merged list contains all elements from all input lists, perfectly sorted from smallest to largest.
Key Observations:
lists = [[1,4,5],[1,3,4],[2,6]][1,1,2,3,4,4,5,6]The linked lists are: [ 1→4→5, 1→3→4, 2→6 ] After combining them into one sorted linked list: 1→1→2→3→4→4→5→6
lists = [][]The input contains no linked lists, so the result is an empty list.
lists = [[]][]There is one linked list in the input, but it is empty. The result is therefore an empty list.
Constraints