题目描述Given a number sequence whose length is n, you
can delete at most k numbers in the sequence.After that you are asked to answer
the maximum length ...
分类:
其他好文 时间:
2014-05-19 22:21:32
阅读次数:
304
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...
分类:
其他好文 时间:
2014-05-18 19:39:55
阅读次数:
355
jvm性能优化及内存分区2012-09-17 15:51:37分类:JavaSome of the
default values for Sun JVMs are listed below.JDK 1.3.1_06 Initial Size Maximum
SizeClient JVM 1MB 32...
分类:
其他好文 时间:
2014-05-18 02:46:12
阅读次数:
311
程序中存在较多的较验,出现Maximum execution time of 30
seconds
exceeded,在网上查到的解决办法,问题解决,备忘来源网址:http://www.oschina.net/code/snippet_262017_19330今天给朋友配置wamp的时候,刚刚搭建好...
分类:
其他好文 时间:
2014-05-17 18:49:00
阅读次数:
248
问题描述
最长递增子序列也称 “最长上升子序列”,简称LIS ( longest increasing subsequence)。设L=是n个不同的实数的序列,L的递增子序列是这样一个子序列Lis=,其中k1
如:求一个一维数组arr[i]中的最长递增子序列的长度,如在序列{ 7, 1, 6, 5, 3, 4, 8 }中,最长递增子序列长度为4,其递增子序列为:1,3,4,8。...
分类:
其他好文 时间:
2014-05-15 15:06:59
阅读次数:
328
【题目】
A sequence of N positive integers (10 N , each of them less than or equal 10000, and a positive integer S (S <
100 000 000) are given. Write a program to find the minimal length of the subse...
分类:
其他好文 时间:
2014-05-15 07:58:17
阅读次数:
329
第三道树的题目,我还是不会,我擦,怎么递归算法还是不能很好理解。看来还得好好研究下递归算法。题目:求一棵树的最大深度。思路:递归地求取左子树最大深度
和 右子树最大深度,返回较大值即为 整棵树的 最大深度。代码:public int maxDepth(TreeNode root) { ...
分类:
其他好文 时间:
2014-05-14 23:07:14
阅读次数:
373
题意:最大连续子序列和,在一个数组中找到和最大的连续子数组
思路:dp, 对于第i个数,有两种选择:把它加入在子数组里,不加入子数组(子数组到此结束)
加不加入子数组,要比较它加入前后子数组的总和是变大了还是变小了,如果变大则加入,变小则不加入
所以,我们需要记录以i-1结尾的子数组的总和,最后的结果在这些总和中取最大的那个
f[i] = max(f[i-1]+a[i],f[i-1]);
max({f[i]})
实现时用两个变量,一个保存f[i-1],一个保存目前为止最大的f[i]
复杂度:时间O(n),空...
分类:
其他好文 时间:
2014-05-14 21:53:14
阅读次数:
250
1、
??
Distinct Subsequences
Given a string S and a string T, count the number of distinct subsequences of T in S.
A subsequence of a string is a new string which is formed from the original str...
分类:
其他好文 时间:
2014-05-14 20:22:58
阅读次数:
275
Total Accepted: 8400 Total Submissions: 38235 My Submissions
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 profi...
分类:
其他好文 时间:
2014-05-14 19:39:53
阅读次数:
275