思路:从左向右遍历数组元素相加求和得到和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
RMQ(Range Minimum/Maximum Query)问题是求区间最值问题。对于长度为 n 的数组 A,进行若干次查询,对于区间 [L,R] 返回数组A中下标在 [L,R] 中的最小(大)值。可以用线段树来解决这个问题,预处理的复杂度是 O(nlogn),查询的复杂度是 O(logn)。更...
分类:
其他好文 时间:
2014-08-08 17:34:26
阅读次数:
200
myeclise10 svn: E210004: Number is larger than maximum 解决方案...
分类:
其他好文 时间:
2014-08-07 23:11:05
阅读次数:
382
Problem Description:
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 tha...
分类:
其他好文 时间:
2014-08-07 15:42:10
阅读次数:
180
题目:Given n points on a 2D plane, find the maximum number of points that lie on the same straight line.题解:这道题就是给你一个2D平面,然后给你的数据结构是由横纵坐标表示的点,然后看哪条直线上的点....
分类:
编程语言 时间:
2014-08-07 02:58:38
阅读次数:
212