← 返回 amazon 的题目列表Find Median in Subsequences
类型:online_judge
Given an integer array, find the minimum and maximum medians of subsequences with length k.
Requirements:
Sort the array.
Find the median of the first k elements of all k-length subsequences.
Find the median of the last k elements of all k-length subsequences.
Return these two medians.
Example:
Input: array = [5, 3, 1, 2, 4], k = 2 Output: [3, 4]
Example
Input
[6, 1, 9, 5, 3], 3