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 of .
Note: Integers in may not be unique.
Complete the function maxMin in the editor below. It must return the integer representing the minimum possible unfairness.
maxMin has the following parameter(s):
k: an integer, the length of the subarrays
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.