All About Medians
A new Amazon intern encountered a challenging task. Currently, the intern has n integers, where the value of the ith 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 an integer, array values, and an integer k, the intern needs to find the maximum and minimum median overall subsequences of length k.
Complete the function medians in the editor below.
medians has the following parameter(s):
int values[n]: 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].
1Example 1

2Example 2

3Example 3

Constraints
Limits and guarantees your solution can rely on.
1 ≤ n ≤ 10^50 ≤ nums[i] ≤ 10^91 ≤ k ≤ n