You will be given a list of integers, , and a single integer . You must create an array of length from elements of such that its unfairness is minimized. Call that array . Unfairness of an array is calculated as
- max denotes the largest integer in
- min denotes the smallest integer in
Pick any two elements, say .
Testing for all pairs, the solution provides the minimum unfairness.
Note: Integers in may not be unique.
Complete the maxMin function in the editor below.
maxMin has the following parameter(s):
int k: the number of elements to select
int arr[n]:: an array of integers
int: the minimum possible unfairness
The first line contains an integer , the number of elements in array .
The second line contains an integer .
Each of the next lines contains an integer where .