Company: Amazon_15nov
Difficulty: medium
Subsequence Medians Problem Description A new Amazon intern encountered a challenging task. Currently, the intern has n integers, where the value of the i-th element is represented by the array element values[i]. The intern is curious to play with arrays and subsequences and thus asks you to join him. Given n integer, array values, and an integer k, the intern needs to find the maximum and minimum overall subsequences of length k. Function Description Complete the function medians in the editor below. medians has the following parameter(s): - vector values: the array of integers. - int k: the given integer. Returns - vector : the maximum and minimum overall subsequences of length k in the form [maximum median, minimum median]. Examples Example 1: Input: n = 3, values = [0, 1, 2], k = 2 Output: [2, 1] Explanation: The subsequences of length k=2 from values = [0, 1, 2] and their respective medians are: - Subsequence [0, 1], median: 0 - Subsequence [0, 2], median: 1 - Subsequence [1, 2],