Company: Amazon_10_feb
Difficulty: medium
Maximum and Minimum Median of Subsequences 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. Given an integer n , an array values , and an integer k , the intern needs to find the maximum and minimum median among all subsequences of length k . Note: A subsequence is a sequence that can be derived from an array by deleting some or no elements without changing the order of the remaining elements. The median of a sequence of length k is the element at index floor((k-1)/2) of the sorted sequence. Example Given n = 3 , values = [1, 2, 3] , and k = 2 . The subsequences of length k and their medians are: Subsequences of length k median [1, 2] 1 [1, 3] 1 [2, 3] 2 Here, the maximum median present is 2 and the minimum median present is 1. Function Description Complete the function medians in the