Given k sorted lists of integers, merge them into one sorted list. The solution should use a heap to efficiently pick the smallest current head across all lists.
lists = array of sorted integer arrays
merged sorted array
Example 1:
Input:
lists = [[1,4,5],[1,3,4],[2,6]]
Output:
[1,1,2,3,4,4,5,6]
Explanation:
All lists are merged while preserving sorted order.
Example 2:
Input:
lists = [[],[1],[]]
Output:
[1]
Explanation:
Empty lists are ignored.