Instructions
User Manual:
Open the PDF directly: View PDF .
Page Count: 2
Download | |
Open PDF In Browser | View PDF |
Max Min 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 Where: - 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 Note: Integers in provides the minimum unfairness of . may not be unique. Function Description 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 Input Format 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 Constraints Output Format An integer that denotes the minimum possible value of unfairness. Sample Input 0 7 3 10 100 300 200 1000 20 30 Sample Output 0 20 . . Explanation 0 Here ; selecting the integers , unfairness equals max(10,20,30) - min(10,20,30) = 30 - 10 = 20 Sample Input 1 10 4 1 2 3 4 10 20 30 40 100 200 Sample Output 1 3 Explanation 1 Here ; selecting the integers , unfairness equals max(1,2,3,4) - min(1,2,3,4) = 4 - 1 = 3 Sample Input 2 5 2 1 2 1 2 1 Sample Output 2 0 Explanation 2 Here . or give the minimum unfairness of .
Source Exif Data:
File Type : PDF File Type Extension : pdf MIME Type : application/pdf PDF Version : 1.4 Linearized : No Title : Creator : wkhtmltopdf 0.12.4 Producer : Qt 4.8.7 Create Date : 2018:06:21 14:39:25Z Page Count : 2 Page Mode : UseOutlinesEXIF Metadata provided by EXIF.tools