

In a Meta-style ranking pipeline, multiple already-sorted candidate lists may need to be combined into one globally sorted stream. Given k sorted integer lists, merge them into a single sorted list.
Implement a function that takes a list of sorted lists and returns one sorted list containing all values from the input lists.
lists, where lists[i] is a sorted list of integers in non-decreasing orderExample 1
lists = [[1,4,5],[1,3,4],[2,6]][1,1,2,3,4,4,5,6]Example 2
lists = [[], [0], [2,2,2]][0,2,2,2]0 <= k <= 10^40 <= total number of elements across all lists <= 10^5-10^9 <= lists[i][j] <= 10^9Aim for a solution better than flattening everything and sorting again when k is large.
lists = [[1,4,5],[1,3,4],[2,6]]Output[1,1,2,3,4,4,5,6]WhyAt each step, choose the smallest current head among the three lists until all values are consumed.lists = [[], [0], [2,2,2]]Output[0,2,2,2]WhyThe empty list is ignored, and duplicates from the third list remain in the output.lists = [[-5,-1,3],[-2,4],[0,7]]Output[-5,-2,-1,0,3,4,7]WhyNegative values and values from different lists are merged into one non-decreasing sequence.0 <= k <= 10^40 <= total number of elements across all lists <= 10^5-10^9 <= lists[i][j] <= 10^9Each list is sorted in non-decreasing orderdef merge_k_sorted_lists(lists):