给定k个排序的数组,请从每个数组中选择一个元素,以使所选元素的最大和最小元素之差最小 [英] Given k sorted arrays, select one element from each array such that the difference of maximum and minimum element of the selected elements is minimum

查看:46
本文介绍了给定k个排序的数组,请从每个数组中选择一个元素,以使所选元素的最大和最小元素之差最小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给定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.

这篇关于给定k个排序的数组,请从每个数组中选择一个元素,以使所选元素的最大和最小元素之差最小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆