Given a string, determine if it is a palindrome, considering only alphanumericcharacters and ignoring cases.For example,"A man, a plan, a canal: Panam...
分类:
其他好文 时间:
2014-11-04 16:49:03
阅读次数:
145
POJ 1159 Palindrome(字符串变回文:LCS)
http://poj.org/problem?id=1159
题意:
给你一个字符串, 问你做少需要在该字符串中插入几个字符能是的它变成一个回文串.
分析:
首先把原字符串和它的逆串进行匹配, 找出最长公共子序列. 那么最长公共子序列的字符串肯定是一个回文串. 所以原串剩下的部分是不构成回文的. 我们只需要添加剩下部分的字符到对应位置, 原串自然就变成了一个回文.
所以本题的解为: n 减去 (原串与逆...
分类:
其他好文 时间:
2014-11-04 13:12:12
阅读次数:
116
1、题目Given a string s, partition s such that every substring of the partition is a palindrome.Return all possible palindrome partitioning of s.For exam...
分类:
编程语言 时间:
2014-11-04 06:40:34
阅读次数:
260
Determine whether an integer is a palindrome. Do this without extra space.要求是不能使用额外的空间,言下之意就是不能先转化成字符串来进行处理,所以得想另外一种办法。额外考虑:负数属于回文数字?思路:直接来截取最低位和最高位来进...
分类:
其他好文 时间:
2014-11-03 22:26:57
阅读次数:
246
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example,"A man, a plan, a canal: Pana...
分类:
其他好文 时间:
2014-11-03 22:26:42
阅读次数:
304
Palindrome
Time Limit: 3000MS
Memory Limit: 65536K
Total Submissions: 53647
Accepted: 18522
Description
A palindrome is a symmetrical string, that is, a string read ide...
分类:
其他好文 时间:
2014-11-01 17:50:47
阅读次数:
179
这个题是走弯路了,刚开始自己DP出了方程,无限MLE,唉
if(s1[i]==s1[j])
dp[i][j]=dp[i+1][j-1];
else dp[i][j]=min(dp[i][j-1],dp[i+1][j]) +1;
后来百度了一下,这个原来是个经典回文串问题,即先将串置反,然后求LCS........
然后就是这题卡时间卡的特别厉害,多用了一次strlen就TLE...
分类:
其他好文 时间:
2014-11-01 16:23:19
阅读次数:
146
/*H - 简单dp 例题扩展Time Limit:3000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64uSubmit StatusDescriptionA palindrome is a symmetrical strin...
分类:
其他好文 时间:
2014-10-31 20:33:20
阅读次数:
134
D - Palindrome Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64uSubmit Status Practice URAL 1297DescriptionThe “U.S. Robots” HQ has...
分类:
编程语言 时间:
2014-10-30 22:28:49
阅读次数:
295
Problem ThreepalindromesA regular palindrome is a string of numbers or letters that is the same forward as backward. For example, the string "ABCDEDCB...
分类:
其他好文 时间:
2014-10-30 07:09:03
阅读次数:
271