
Given an array lists of k sorted singly linked lists, merge them into one sorted linked list and return the head of the merged list. Each input list is sorted in non-decreasing order, and empty lists may appear in the input.
Example 1:
Input: lists = [[1,4,5],[1,3,4],[2,6]]
Output: [1,1,2,3,4,4,5,6]
Explanation: Merging all three sorted lists produces one fully sorted list.
Example 2:
Input: lists = []
Output: []
Explanation: There are no lists to merge, so the result is empty.
0 <= k <= 10^40 <= total number of nodes across all lists <= 10^5-10^4 <= Node.val <= 10^4lists = [[1,4,5],[1,3,4],[2,6]]Output[1,1,2,3,4,4,5,6]WhyThe smallest current head is repeatedly chosen until all nodes are merged into one sorted list.lists = []Output[]WhyWith no input lists, the merged result is empty.lists = [[], [0]]Output[0]WhyEmpty lists are ignored, so the result is just the non-empty sorted list.0 <= k <= 10^40 <= total number of nodes across all lists <= 10^5-10^4 <= Node.val <= 10^4Each individual linked list is sorted in non-decreasing orderdef merge_k_lists(lists):