Company: Amazon_5sep
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 integers, array values , and an integer k , the intern needs to find the maximum and minimum overall subsequences of length k . Complete the function medians in the editor below. The function is expected to return an INTEGER_ARRAY . The function accepts the following parameters: int values[] : the value of integers int k : the given integer Returns: int[] : the maximum and minimum overall subsequences of length k in the form [maximum median, minimum median] . Examples Example 1: Input: n = 3, values = [1, 2, 3], target = 2 Output: [2, 1] Explanation: Given values = [1, 2, 3] and k = 2 , the subsequences of length k and their medians are: Subsequences of length k median [1, 2] 1 [