摘要:
Problem Description:Describe an O(n)-time algorithm that, given a set of S of n distinct numbers and a positive integerd k ≤ n, determines the k numbers in S that are closest to the median of S.问题描述:有一个长为n的数组且数组元素互不相同,要求以O(n)的时间复杂度找到离数组中值最近(与中值的差的绝对值最小)的k个数(k ≤ n)。问题升级:题目要求是找离中值最近的 k 个数,这里做一下推广,找离数组 阅读全文