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...
分类:
其他好文 时间:
2015-02-12 20:06:06
阅读次数:
216
题意:给个n*n的矩阵,所有子矩阵中 ,和最大等于多少。
做法:
首先要理解一个O(n)的算法 。
给一个数组 求连续和的最大值。 可以用一个sum来从下标0开始计算和,不断取最大值。当加和小于0的时候 初始化为0;
如 3 -4 5 1 -2 第一个步加和是3,再加上第二个-4 ,sum就变成-1了,所以要初始化sum为0,再加5 ,再加1, 最后得到最大值为6。
然后对于矩阵,我们可以先预处理,sum[ i ] [ j ]为 第 i 列的 前j项和;
然后枚举 两列 i,j ,然后k...
分类:
其他好文 时间:
2015-02-12 16:21:42
阅读次数:
135
整整10个月后第二次搞这个问题才搞懂........第一次还是太随意了。解题思路:经过打表可得规律答案要么是0 要么是2的N次 - 1要得到最大的XOR值,其值一定是2的N次 - 1即在 l 和 r 的二进制中,从左到右遍历过去,如果碰到 (2 ^ i) & l 为 1 , (2 ^ i) & r ...
分类:
其他好文 时间:
2015-02-12 00:32:59
阅读次数:
684
absolute : to specify an absolute time for a time-range (in time-range configuration mode)no absolutebuffer-length : to specify the maximum length of ...
分类:
移动开发 时间:
2015-02-11 21:50:24
阅读次数:
247
Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest le...
分类:
其他好文 时间:
2015-02-10 23:02:36
阅读次数:
218
本文转自:http://www.linuxidc.com/Linux/2013-06/86057.htm关于ora-01000:超出最大可打开的游标数 的一点理解ORA-01000: maximum open cursors exceeded"怎么解决ERROR at line 1:ORA-0100...
分类:
其他好文 时间:
2015-02-10 20:08:34
阅读次数:
162
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 larg...
分类:
其他好文 时间:
2015-02-10 15:26:37
阅读次数:
160
Given a stringS, find the longest palindromic substring inS. You may assume that the maximum length ofSis 1000, and there exists one unique longest pa...
分类:
其他好文 时间:
2015-02-10 15:06:02
阅读次数:
172
占位符{0}对应属性{1}对应minimum{2}对应maximum[StringLength(15, MinimumLength = 6, ErrorMessage = "密码长度必须在{2}和{1}之间")]先创建一个资源文件为了实现这种验证效果资源文件里可以这样写然后新建一个类,这个类主要实现...
分类:
其他好文 时间:
2015-02-10 14:54:35
阅读次数:
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,...
分类:
其他好文 时间:
2015-02-10 14:50:48
阅读次数:
126