问题: Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may co...
分类:
其他好文 时间:
2014-10-10 00:18:11
阅读次数:
398
1.概述RMQ(Range Minimum/Maximum Query),即区间最值查询,是指这样一个问题:对于长度为n的数列A,回答若干询问RMQ(A,i,j)(i,jO(nlogn){for(int j = 1; j #include #include using namespace std;c...
分类:
其他好文 时间:
2014-10-09 23:36:27
阅读次数:
627
a(i):以节点i作为终点的单边最大路径和
b(i):以节点i作为终点的双边边最大路径和
a(i) = max{ i->val,
i->val + max{a(i->left), a(i->right) }};
b(i) = max{ i->val, i->val + max{a(i->left), a(i->right) } ,
i->val + a(i->left) + a(...
分类:
其他好文 时间:
2014-10-09 22:49:47
阅读次数:
141
Given an array of non-negative integers, you are initially positioned at the first index of the array.
Each element in the array represents your maximum jump length at that position.
Determine i...
分类:
其他好文 时间:
2014-10-09 16:59:57
阅读次数:
203
[leetcode]Given a binary tree, find the maximum path sum....
分类:
其他好文 时间:
2014-10-09 16:29:28
阅读次数:
161
Maximum Subarray
Total Accepted: 28381 Total Submissions: 83696 My Submissions
Find the contiguous subarray within an array (containing at least one number) which has the largest sum.
For exam...
分类:
其他好文 时间:
2014-10-09 16:27:18
阅读次数:
237
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-10-09 01:08:37
阅读次数:
231
很久没练只能看别人代码了 1 class Solution { 2 public: 3 int maxProduct(int A[], int n) { 4 if (n == 0) return 0; 5 int curMax, curMin, ans; 6 ...
分类:
其他好文 时间:
2014-10-09 00:48:07
阅读次数:
218
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-10-09 00:23:07
阅读次数:
218
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,?5,4],
the contiguous subarray [4,?1,2,1] ha...
分类:
其他好文 时间:
2014-10-08 18:06:55
阅读次数:
163