Minimum Absolute Difference

96 Views Asked by At

Given 'n' numbers, how do we choose 'k' (k<=n) numbers such that the sum of the absolute difference between each element in 'n' and the closest element in 'k' is the minimum. Each of these 'n' numbers are between 1 and 1000.

For k=1, this is the median of the 'n' numbers and for k=n, this is the 'n' numbers itself. But what if 'k' is something else? How do I approach this problem?