#include
#include
#define SIZE 10
#define MAXVALUE 0x7fffffff
using namespace std;
//题目是:求一个字符串中最小字串.
//求最小字串,比求最大字串难的多,下面有我的求最大字串代码,我没有想到更好的方法,下面的这个方法虽然空间复杂度太大,可是时间复杂度是比较快的。
template
struct Node
{...
分类:
编程语言 时间:
2015-04-27 11:23:56
阅读次数:
185
解题思路:环形数组最大字串,穿过和不穿过的DP解题代码: 1 // File Name: c.cpp 2 // Author: darkdream 3 // Created Time: 2015年04月12日 星期日 19时52分24秒 4 5 #include 6 #include 7 #inc....
分类:
其他好文 时间:
2015-04-13 20:46:41
阅读次数:
108
背景:上次比赛就没有做出来,回来根据实际意义半天也想不出如何dp,结果从猜转移方程入手,竟然想对了!开始想把空间优化到一维数组,没有想到要用同维度左边的值wa了。
思路:
dp[i][j]=max{max[i-1][j],max[i][j-1],max[i-1][j-1]+(a[i] == b[j])}
//dp[i][j]定以为,a串的前i个字符和b串的前b个字符的最大字串和,为选a串的第i...
分类:
其他好文 时间:
2015-04-11 09:01:59
阅读次数:
161
Maximum sum
Time Limit: 1000MS
Memory Limit: 65536K
Total Submissions: 34697
Accepted: 10752
Description
Given a set of n integers: A={a1, a2,..., an}, we define a ...
分类:
其他好文 时间:
2015-03-05 14:48:35
阅读次数:
148
这道题就是给出一串数,然后要我们求出其最大字串和!
然后由于要输出字串的起末位置,所以记得保存好位置的值!
代码中关键地方有详细的注释!可以在看代码的时候看一下!
注意下:就是在两组数据间是需要用一行空行来隔开的,
所以输出时需要注意下!
代码如下:
#include
#include
#include
using namespace std;
int n,nu...
分类:
其他好文 时间:
2014-11-04 21:15:24
阅读次数:
243
子串和
时间限制:5000 ms | 内存限制:65535 KB
难度:3
描述给定一整型数列{a1,a2...,an},找出连续非空子串{ax,ax+1,...,ay},使得该子序列的和最大,其中,1
输入第一行是一个整数N(N
每组测试数据的第一行是一个整数n表示序列中共有n个整数,随后的一行里有n个整数I(-100=
输出对于每组测试数据输出和最大...
分类:
其他好文 时间:
2014-11-03 22:33:48
阅读次数:
238
左右两次遍历,记录以当前元素结尾的左边最大字串和以及右边最大字串和,最后遍历,相加 1 // you can also use includes, for example: 2 // #include 3 #include 4 #include 5 int solution(vector &A...
分类:
其他好文 时间:
2014-09-18 11:10:43
阅读次数:
197
Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without
repeating letters for "abcabcbb" is "abc", which the length is 3. Fo...
分类:
其他好文 时间:
2014-06-08 16:27:47
阅读次数:
231
题意:给你一个数组,问你交换最多K个数以后,最大子串和为多少;解题思路:枚举这个数组最大字串和的起点和终点,然后优先队列交换这段里面的小数去换外面的大数,即可求出答案!解题代码:
1 // File Name: c.cpp 2 // Author: darkdream 3 // Created Ti...
分类:
其他好文 时间:
2014-04-29 21:44:33
阅读次数:
605