给定k个排序的数组,从每个数组中选择一个元素,以使所选元素的最大元素和最小元素之差最小.k = 3的示例
Given k sorted arrays, select one element from each array such that the difference of maximum element and minimum element of the selected elements is minimum. Example for k = 3
array1:1 13 27 30
array1 : 1 13 27 30
array2:16 20 29
array2 : 16 20 29
array3:2 3 14 18 19 22 25 28
array3 : 2 3 14 18 19 22 25 28
ans:2选定的元素(27、29、28)
ans: 2 selected elements (27, 29, 28)
推荐答案以k个排序的数组/列表中最短的范围是您要寻找的标准问题,这是解决方法.
Shortest range in k sorted arrays/lists is the standard problem you are looking for, here is it's solution.