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
As an example, consider the array with a of . Pick any two elements, test .
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. It must return an integer that denotes the minimum possible value of unfairness.
maxMin has the following parameter(s):
k: an integer, the number of elements in the array to create
arr: an array of integers .
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 .
An integer that denotes the minimum possible value of unfairness.