子序列的最大几个值 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 byone 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,这个不一定。但是通常情况下,是红黑树,所以就是平衡树。
相关文章推荐
- leetcode Maximum Subarray 最大子序列
- 53/152 Maximum Product Subarray /Maximum Subarray(子序列之 和/积 最大)
- maximum-subarray 序列最大连续和 贪心
- [leetcode]Maximum Product Subarray最大子序列乘积
- Maximum Product Subarray(最大连续乘积子序列)
- 求连续最大子序列积 - leetcode. 152 Maximum Product Subarray
- Maximum Subarray 动态规划 最大连续子序列和
- [Lintcode]Maximum Product Subarray乘积最大子序列
- LeetCode: Maximum Product Subarray && Maximum Subarray &子序列相关
- 【Leetcode】Maximum Subarray in JAVA
- Leetcode 152 Maximum Product Subarray 子数组最大乘积
- dynamic programming 之Maximum Sub-Sequence Sum(最大子序列和问题)
- 最大和子数组与最大积子数组(Largest Sum Contiguous Subarray & Maximum Product Subarray)
- Solution to Maximum Subarray in linear-time algorithm with time complexity is O(n)
- 所有子序列的最大值 Maximum of all subarrays of size k
- LeetCode OJ 之 Maximum Product Subarray (子数组的最大积)
- 【算法导论学习-007】最大子数组和问题(Maximum subarray problem)
- 3.子数组的最大和[MaximumContinuousSubArray]
- 【LeetCode】Maximum Product Subarray 求连续子数组使其乘积最大
- Maximum Subarray 最大连续和