UVa 10617 Again Palindrome(经典回文串区间DP)
题意:
给定一个字符串s,对s进行删除操作,使得剩下的子串是回文字符串,问最多有多少种这种子串。
思路:
涉及到回文字符串,首先要想到的肯定是区间DP,如何写出状态转移方程?
直接从题意切入:dp[i, j]表示区间[i, j]最多有多少个这样的子串。
1. s[i] == s[j] 去...
分类:
其他好文 时间:
2015-04-28 18:27:07
阅读次数:
192
题目链接:http://poj.org/problem?id=3974题意:求一给定字符串最长回文子串的长度思路:直接套模板manacher算法code: 1 #include 2 #include 3 #include 4 using namespace std; 5 const int M...
分类:
其他好文 时间:
2015-04-28 15:36:44
阅读次数:
139
题目链接:http://codeforces.com/gym/100548今天晚上突然有了些兴致去学习一下数据结构,然后就各种无意中看到了Palindrome Tree的数据结构,据说是2014年新出的数据结构,也让我回想起了西安打铁时候的经历。这道题的题意其实是比较清晰的,给你两个长度200000...
分类:
其他好文 时间:
2015-04-28 07:03:34
阅读次数:
301
题目:LeetCode 009 Palindrome Number题意:判断一个整数是否为回文数,不要用额外空间思路:我不会不用额外空间的方法,需要利用一个长度为20以内的字符串。将整数先写入一个字符串,然后判断首位字符是否相等即可。代码如下: 1 class Solution { 2 public...
分类:
其他好文 时间:
2015-04-27 19:41:45
阅读次数:
130
判断字符串是否是回文。字母、数字都算在内;空串也是回文。【思路】经典回文,两个指针,一个从前向后遍历,一个从后向前,遇到不是要求字符的就跳过。前后指针位置交叉(i>j),则遍历结束。特殊的地方在于,包含字母和数字,如果一一排除,代码很繁琐。【my code】bool isPalindrome(str...
分类:
其他好文 时间:
2015-04-27 09:31:19
阅读次数:
118
Determine whether an integer is a palindrome. Do this without extra space.解题思路:由于题目中给定不能使用额外空间开销,因此不能转为String类型,我们需要一位一位处理。Java代码如下: static public boo...
分类:
编程语言 时间:
2015-04-26 10:42:59
阅读次数:
131
问题描述:Determine whether an integer is a palindrome. Do this without extra space.Some hints:Could negative integers be palindromes? (ie, -1)If you are t...
分类:
编程语言 时间:
2015-04-25 14:54:15
阅读次数:
167
Time Limit:15000MSMemory Limit:65536KTotal Submissions:5121Accepted:1834DescriptionAndy the smart computer science student was attending an algori...
分类:
其他好文 时间:
2015-04-24 12:06:40
阅读次数:
134
统计前半个回文串
#include
using namespace std;
#define For(i,n) for(int i=1;i=k;i--)
#define Rep(i,n) for(int i=0;i<...
分类:
其他好文 时间:
2015-04-23 13:24:32
阅读次数:
143
Palindrome NumberDetermine whether an integer is a palindrome. Do this without extra space.Some hints:Could negative integers be palindromes? (ie, -1)...
分类:
其他好文 时间:
2015-04-21 20:22:35
阅读次数:
130