Company: Amazon_30oct
Difficulty: medium
Medians Problem Description You are given an array values of n integers and an integer k . Consider every subsequence of values of length exactly k -- any choice of k positions, kept in their original order. For each such subsequence, sort it in non-decreasing order and take the element at 0-based index (k - 1) / 2 (integer division). That element is the subsequence's median; for an even k it is the lower of the two middle values. Report the largest and the smallest median that any length- k subsequence can have. Function Description Complete the function medians in the editor below. medians has the following parameters: values_count : the number of elements. values[values_count] : the array. k : the subsequence length. Returns: int[] -- two integers, the maximum median followed by the minimum median. Input Format The first line contains the integer values_count . The second line contains values_count space-separated integers. The third line contains the integer k . Output Format Print