← 返回 oracle 的题目列表Merge K Sorted Lists with Key-Value Pairs
类型:online_judge
Given k linked lists, each containing (key, value) pairs, return a merged list that is sorted by keys. If the key appears in more than one list, the latest occurrence in the lists should overwrite the previous ones.
Input: k = 3 l0 = [(1,70),(3,20),(5,30)] l1 = [(2,40),(3,50)] l2 = [(1,15),(4,80),(5,90)]
Output: answer = [(1,15),(2,40),(3,50),(4,80),(5,90)]
Example
Input
3
[(1,70),(3,20),(5,30)]
[(2,40),(3,50)]
[(1,15),(4,80),(5,90)]