Find the maximum and minimum median over all length-k subsequences of an array.
Unlock detailed company stats for this questionUpgrade
Given an array values of size n and an integer k, consider all subsequences of length k. For each, sort it and take the median (the lower median for even k). Return [maximum median, minimum median]. Example: values = [1, 2, 3], k = 2 gives [2, 1]. Constraints: 1 <= n <= 1e5, 0 <= values[i] <= 1e9, 1 <= k <= n.
Format · Part of Amazon's SDE-1 online assessment.
Also asked as · Find the maximum and minimum median over all length-k subsequences.
Community answers
No answers contributed by the community yet.


