Find thekth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element.For exampl...
分类:
其他好文 时间:
2015-10-21 22:33:55
阅读次数:
212
Find the contiguous subarray within an array (containing at least one number) which has the largest product.For example, given the array[2,3,-2,4],the...
分类:
其他好文 时间:
2015-10-21 06:52:27
阅读次数:
225
Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array[?2,1,?3,4,?1,2,1,...
分类:
其他好文 时间:
2015-10-21 06:51:01
阅读次数:
173
链接:https://leetcode.com/problems/maximal-rectangle/【描述】Given a 2D binary matrix filled with '0's and '1's, find the largest rectangle containing all o...
分类:
其他好文 时间:
2015-10-20 12:09:18
阅读次数:
242
A variantion to "largest\smallest consecutive subarray". Idea is, at position i, the current max diff is max(max_left[i] - min_right[i+1], max_right[i...
分类:
其他好文 时间:
2015-10-18 14:01:57
阅读次数:
174
原题链接在这里:http://www.lintcode.com/en/problem/kth-largest-element/#采用的quickSelect方法,取出pivot, 比pivot 小的都放在左边,比pivot大的都放在右边,若是pivot左边包括pivot的个数恰巧等于k, 就返回pi...
分类:
其他好文 时间:
2015-10-17 07:01:06
阅读次数:
294
看到这个题目,第一时间应该推出的是直方图中最大矩形的高度必然和某一个柱子的高度相等。因此,容易想到遍历数组,对于某一立柱,往左右两边扩展,看看以当前立柱的高度最多能包含多大的矩形面积,这种方法的时间复杂度为O(n^2),会超时。正确而高效的方法是网上广泛讨论的一种方法,借助栈来实现算法,可达到O(n)的时间复杂度。...
分类:
其他好文 时间:
2015-10-13 17:21:25
阅读次数:
248
Problem DescriptionLike everyone, cows enjoy variety. Their current fancy is new shapes for pastures. The old rectangular shapes are out of favor; new...
分类:
其他好文 时间:
2015-10-11 16:39:11
阅读次数:
241
(referrence: GeeksforGeeks, Kth Largest Element in Array)This is a common algorithm problem appearing in interviews.There are four basic solutions.Sol...
分类:
其他好文 时间:
2015-10-10 01:33:06
阅读次数:
208
Givennnon-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the histog...
分类:
其他好文 时间:
2015-10-08 21:27:26
阅读次数:
186