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...
分类:
其他好文 时间:
2014-08-17 16:55:02
阅读次数:
202
GeoServer WMS地图请求内存限制问题
1.Rendering request would use 71833KB, whilst the maximum memory allowed is 65536KB
2.java.lang.NegativeArraySizeException null
3.java.lang.OutOfMemoryError: Java heap space Java heap space...
分类:
其他好文 时间:
2014-08-16 19:51:11
阅读次数:
236
题目链接
题意:给出一个环形矩阵,也就是第一行和最后一行是相连的,第一列和最后一列是相连的,求最大的子矩阵的和
思路:只要将矩阵复制四个,那么就可以按照求一个矩阵内最大子矩阵之和的做法去做,即枚举所有子矩阵的和,更新最大值。要注意在转换后的大矩阵,枚举的子矩阵规格是有范围的。
代码:
#include
#include
#include
#include
...
分类:
其他好文 时间:
2014-08-16 18:32:40
阅读次数:
240
本题需要使用选择矩阵的程序求解,这个和Leetcode上的一个程序是一样道理的。如果使用额外空间,那么是很容易做到的,这里不使用额外空间,直接使用到位操作,空间效率是O(1),这是个非常漂亮的到位旋转程序。
题意还是很重要,这次看错了一句话,就WA了一次:
The maximum amount of cells which contains two equal numbers after ov...
分类:
其他好文 时间:
2014-08-15 22:35:29
阅读次数:
288
动态规划与贪心相关:{POJ}{2479}{Maximum Sum} (DP)摘要: 题意:给定n个数,求两段连续子列的最大和。思路:先从左向右dp,求出一段连续子列的最大和,再从右向左dp,求出两段连续子列的最大和,方法还是挺经典的。{POJ}{1036}{Gansters} (DP)摘要: 题意...
分类:
其他好文 时间:
2014-08-15 22:20:09
阅读次数:
309
题意:
给出一个图片,分成N×N个单元格,有M次操作,每次操作将(x,y)的值变为以(x,y) 为中心L(L为奇数)为边长的区域内的最小值和最大值的均值(floor((maximum+minimum)/2)),并输出该值。
分析:
明显的二维线段树的单点更新和区间查询,维护最值。
更新肯定是先在二维内找到叶子节点的那棵线段树,然后再在这棵树上更新,这部分很简单,就想成一维的写。但是这毕竟是二维线段树,二维的部分也需要维护,当然这部分比较麻烦,我们先想一想一维的:一维的节点维护的是值,我们只要根据它的左右儿子...
分类:
其他好文 时间:
2014-08-15 12:58:58
阅读次数:
224
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