Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 40121

subset with elements that are furthest apart from each other

$
0
0

I have an interview question that I can't seem to figure out. Given an array of size N, find the subset of size k such that the elements in the subset are the furthest apart from each other.

Example:

Array = [1,2,6,10]
k = 3    
answer = [1,6,10]

UPDATE : meaning of furthest apart : the difference b/w any two elements in the subset is mimimum .


Viewing all articles
Browse latest Browse all 40121

Trending Articles