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

32 篇文章 0 订阅

子序列的最大几个值 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,这个不一定。但是通常情况下,是红黑树,所以就是平衡树。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值