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 largest produ...
分类:
其他好文 时间:
2015-04-17 22:23:08
阅读次数:
170
题目大意:求出两个串的公共子序列的长度
LCS的入门题,读懂题了直接模板就可以
#include
#include
using namespace std;
const int N=1000;
int a[N][N];
int LCS(const char *s1, const char *s2)
{// s1:0...m, s2:0...n
int m = strlen(s...
分类:
其他好文 时间:
2015-04-17 22:21:07
阅读次数:
206
题目的大意是:给出一序列,求出该序列的最长上升子序列的最大长度。
思路:
a: 1 7 3 5 9 4 8
dp: 1 2 2 3 4 3 4
#include
#include
using namespace std;
const int MAXN = 1005;
int main()
{
int n;
while( cin>>n )
{...
分类:
其他好文 时间:
2015-04-17 22:19:25
阅读次数:
169
题目如下:Givennpoints on a 2D plane, find the maximum number of points that lie on the same straight line.再简单不过的一题了,懒得写解释直接上代码了。/** * Definition for a poi...
分类:
其他好文 时间:
2015-04-17 21:45:48
阅读次数:
110
Given an unsorted array, find the maximum difference between the successive elements in its sorted form.Try to solve it in linear time/space.Return 0 ...
分类:
其他好文 时间:
2015-04-17 15:17:10
阅读次数:
148
Longest Palindromic Substring
Given a string S,
find the longest palindromic substring in S.
You may assume that the maximum length of S is
1000, and there exists one unique longest palindrom...
分类:
其他好文 时间:
2015-04-17 13:55:59
阅读次数:
162
Given a sequence of K integers { N1, N2, ..., NK }. A continuous subsequence is defined to be { Ni, Ni+1,
..., Nj } where 1 Maximum Subsequence is the continuous subsequence which has the largest su...
分类:
其他好文 时间:
2015-04-17 11:37:02
阅读次数:
105
Say you have an array for which theithelement is the price of a given stock on dayi.Design an algorithm to find the maximum profit. You may complete a...
分类:
其他好文 时间:
2015-04-16 23:39:29
阅读次数:
145
题目链接:Maximum Depth of Binary Tree
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 leaf node.
这道题...
分类:
其他好文 时间:
2015-04-16 10:25:57
阅读次数:
123
题目大意: 对整数串S,求其两个不相交的子串s1、s2,使得s1+s2的值最大。方法:DP, lt[i]代表以第i个元素结尾的串最大值
rt[i]代表以第i个元素开头的串的最大值
那么设置一个rtm[i]代表取后i个元素之中最大连续子串的和很显然,lt[i]=max(a[i],lt[i-1]+a[i]);
rt[i]=max(a[i],rt[i+1]+a[i]);
rtm[i]=ma...
分类:
其他好文 时间:
2015-04-15 21:31:49
阅读次数:
142