Find the contiguous subarray within an array (containing at least one number) which has the largest sum.
分类:
其他好文 时间:
2014-06-27 11:43:25
阅读次数:
173
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,...
分类:
其他好文 时间:
2014-06-26 15:10:47
阅读次数:
168
Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing all ones and return its area.时间复杂度O(n^3),最大全1子矩阵,利用直方图求解,可以参考对...
分类:
其他好文 时间:
2014-06-26 15:08:46
阅读次数:
164
For a period before the recent nationwide gold industry shutdown, Duration was Zimbabwe’s second largest gold producer. Up until that point, it had en...
分类:
其他好文 时间:
2014-06-25 23:20:27
阅读次数:
274
题目:数组中有一个数字出现的次数超过数组长度的一半,请找出这个数字方法一:如果把这个数字排序,那么排序之后位于数组中间的数字一定就是出现次数超过数组长度一半的数字这个数字就是统计学中的中位数,即长度为n的数组中第n/2大的数字在数组中得到任意第k大数字,这一问题有O(n)解,注:这里第kth个元素,...
分类:
其他好文 时间:
2014-06-25 16:47:12
阅读次数:
345
题目:输入n个整数,找出其中最小的K个数方法一:直接std::sort,T(n) = O(nlgn)方法二:直接std::nth_element T(n) = O(n) 但是修改了原数组void MinKth(std::vector& num, int kth, std::vector& resul...
分类:
其他好文 时间:
2014-06-25 12:35:07
阅读次数:
216
Given an index k, return the
kth row of the Pascal's triangle.
For example, given k = 3,
Return [1,3,3,1].
Note:
Could you optimize your algorithm to use only
O(k) extra space?
...
分类:
其他好文 时间:
2014-06-22 21:31:26
阅读次数:
214
Given an index k, return the kth row of the Pascal's triangle.
For example, given k = 3,
Return [1,3,3,1].
Note:
Could you optimize your algorithm to use only O(k) extra space?
思路:最简单的方法就是按...
分类:
其他好文 时间:
2014-06-18 12:40:54
阅读次数:
265
Kth number
Time Limit: 15000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 4585 Accepted Submission(s): 1461
Problem Description
Give you a sequenc...
分类:
其他好文 时间:
2014-06-17 23:04:29
阅读次数:
246