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 complet...
分类:
其他好文 时间:
2014-08-14 23:19:46
阅读次数:
240
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 complet...
分类:
其他好文 时间:
2014-08-14 23:05:56
阅读次数:
165
Given a binary tree, find the maximum path sum.The path may start and end at any node in the tree.For example:Given the below binary tree, 1 ...
分类:
其他好文 时间:
2014-08-14 20:20:09
阅读次数:
206
题目链接:点击打开链接
题意:
第一行 n m
n个vector
下面n行 第一个数字u表示vector 的大小,然后后面u个数字给出这个vector
最后一行m个数字
表示把上面的vector拼接起来
得到一个大序列,求这个大序列的最大子段和
先预处理出每个vector的最大子段和,左起连续最大,右起连续最大,所有数的和
然后dp 一下。。
#include ...
分类:
其他好文 时间:
2014-08-13 18:55:07
阅读次数:
266
思路:从左向右遍历数组元素相加求和得到和sum,若sum小于0,必然会对总的和有损耗,因此将sum重置为0,从当前位置继续重复上述过程,直到数组结束,与此同时设置max变量记录求和过程中遇到的最大值。
执行完上述过程,判断max等于0(max初值为0),若大于0,max为所求结果,返回max。
若仍然等于0说明求和过程中未出现过正数,数组中全是负数或0,此时数组最大和就是数组中最大的最...
分类:
其他好文 时间:
2014-08-13 15:01:56
阅读次数:
211
Description
YH gave Qz an odd matrix consists of one or zero. He asked Qz to find a square that has the largest area. The problem is not so easy, that means the square you find must not contai...
分类:
其他好文 时间:
2014-08-12 19:11:04
阅读次数:
208
1.4GT调优 Stackoverflow有一则关于4GT提问:http://stackoverflow.com/questions/2883206/maximum-size-of-application-memory-space-on-32-x86-2-gb-or-1-gb/2883252#28....
Binary Tree Maximum Path SumGiven a binary tree, find the maximum path sum.The path may start and end at any node in the tree.For example:Given the be...
分类:
其他好文 时间:
2014-08-11 21:13:02
阅读次数:
219
Maximum SubarrayFind the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array[?...
分类:
其他好文 时间:
2014-08-10 21:18:20
阅读次数:
232
Given n points on a 2D plane, find the maximum number of points that lie on the same straight line.思路:对于两个点(x1,y1)和(x2,y2),其所确定的直线方程为:(x1-x2)*y + (y2-...
分类:
其他好文 时间:
2014-08-09 23:03:49
阅读次数:
317