a01
a01

Reputation: 11

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

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

array2 : 16 20 29

array3 : 2 3 14 18 19 22 25 28

ans: 2 selected elements (27, 29, 28)

Upvotes: 1

Views: 1405

Answers (2)

AviKKi
AviKKi

Reputation: 1204

Shortest range in k sorted arrays/lists is the standard problem you are looking for, here is it's solution.

Upvotes: 2

Ajay Kulkarni
Ajay Kulkarni

Reputation: 1

May be you are looking for this answer : https://www.geeksforgeeks.org/find-smallest-range-containing-elements-from-k-lists/ .
It's not contributed to me, I just found this on geeksforgeeks while searching for the same thing as you.

Upvotes: 0

Related Questions