There are n arrays of k size each. a0[0],a0[1],......a0[k-1] a1[0],a1[1],......a1[k-1] . . . an-1[0],an-1[1], .... an-1[k-1] Now a Set of size n is constructed by taking any value randomly from each of the arrays. e.g one such set can be {a0[0],a1[3],a2[2],.... an-1[k-1]} My goal is to find out the min and max elements in all possible Sets such that the difference between the min and max is the lowest.