您的位置:首页 > 其它

子序列的最大几个值 maximum k elements in a subarray

2014-11-24 07:18 369 查看

子序列的最大几个值 maximum k elements in a subarray

U have given large stream of m size and you have size of n window . you have to find the k minimum in each window . we are shifting the window by
one at every iteration.

解答: I have used self balancing tree.First i have entered n element in tree and do in order traversal upto k to find k minimum element.Now shift the
window by one .Now we to remove first element(logn time req) and insert the new element(logn time).

注意:C++的STL里的set是用binary search tree实现的,到底是不是balanced binary search tree,这个不一定。但是通常情况下,是红黑树,所以就是平衡树。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: