You are given an array of k linked-lists lists, each linked-list is sorted in ascending order.
Merge all the linked-lists into one sorted linked-list and return it.
Input: lists = [[1,4,5],[1,3,4],[2,6]]
Explanation: The linked-lists are:
merging them into one sorted list:
Problem Category Hard!!!, Omo
The first idea I got was to merge the lists to a single list and the sort the whole merged lists, using a sorting algorithm, like merge sort.
Think I think of complexity and how to simplify it.
Which is why should I merge the list all.
I then get the first list,
combine the first with second link sorted,
continuously until I reach the end of the list.
Complexity is O(n+k)
Space Complexity O(k)