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],t...
分类:
其他好文 时间:
2014-11-27 01:29:03
阅读次数:
187
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?
这个问题比较简单。
v...
分类:
其他好文 时间:
2014-11-26 14:23:25
阅读次数:
245
Description
Now we have a number, you can swap any two adjacent digits of it, but you can not swap more than K times. Then, what is the largest probable
number that we can get after you...
分类:
其他好文 时间:
2014-11-25 09:20:31
阅读次数:
247
Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing all ones and return its area.Analysis:For each position (i,j),...
分类:
其他好文 时间:
2014-11-24 06:28:38
阅读次数:
192
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...
分类:
其他好文 时间:
2014-11-23 17:19:58
阅读次数:
254
ProblemImplement an algorithm to find the kth to last element of a singly linked list.Solution 1 public static ListNode findElement(ListNode head, int...
分类:
其他好文 时间:
2014-11-22 10:38:33
阅读次数:
168
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...
分类:
其他好文 时间:
2014-11-21 23:06:22
阅读次数:
242
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 contiguous subarray [2,3] has the largest ...
分类:
其他好文 时间:
2014-11-21 18:43:17
阅读次数:
196
TopK问题,即寻找最大的K个数,这个问题非常常见,比如从1千万搜索记录中找出最热门的10个关键词.
方法一:
先排序,然后截取前k个数.
时间复杂度:O(n*logn)+O(k)=O(n*logn)。
方法二:
最小堆.
维护容量为k的最小堆.根据最小堆性质,堆顶一定是最小的,如果小于堆顶,则直接pass,如果大于堆顶,则替换掉堆顶,并heapify整理堆,其中heapify...
分类:
编程语言 时间:
2014-11-21 18:42:10
阅读次数:
225
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 contiguous subarray [2,3] has the largest ...
分类:
其他好文 时间:
2014-11-21 18:41:59
阅读次数:
174