码迷,mamicode.com
首页 >  
搜索关键字:palindrome    ( 1561个结果
动态规划+滚动数组 -- POJ 1159 Palindrome
给一字符串,问最少加几个字符可以让它成为回文串 比如 Ab3bd 最少需要两个字符可以成为回文串 dAb3bAd 思路: 动态规划 DP[i][j] 意味着从 i 到 j 这段字符变为回文串最少要几个字符,枚举子串长。 if str[i] == str[j]: DP[i][j] = DP[i + 1][j - 1] else: DP[i][j] = min( DP[i +...
分类:其他好文   时间:2014-07-19 02:35:45    阅读次数:198
poj 3974 Palindrome
边吃边敲,效率就是高 代码如下: #include #include #define MAX 1000050 char s[MAX],ss[MAX*2]; int p[MAX*2]; int min(int a,int b){return a>b?b:a;} int main() { int i,id,mx,max,n,j; j=1; while(scanf("%s",s...
分类:其他好文   时间:2014-07-19 02:31:25    阅读次数:166
[LeetCode] Palindrome Partitioning II
Given a strings, partitionssuch that every substring of the partition is a palindrome.Return the minimum cuts needed for a palindrome partitioning ofs...
分类:其他好文   时间:2014-07-19 00:05:43    阅读次数:200
H_Dp
/* H - 简单dp 例题扩展 Time Limit:3000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Submit Status Description A palindrome is a symmetrical string, that is, a string read identically from ...
分类:其他好文   时间:2014-07-18 22:23:07    阅读次数:235
[leetcode]Palindrome Number
Palindrome NumberDetermine whether an integer is a palindrome. Do this without extra space.click to show spoilers.Some hints:Could negative integers b...
分类:其他好文   时间:2014-07-18 15:17:26    阅读次数:201
UVa 11583 Partitioning by Palindromes
?? Description Problem H: Partitioning by Palindromes We say a sequence of characters is a palindrome if it is the same written forwards and backwards. For example, 'racecar' is a palindrome,...
分类:其他好文   时间:2014-07-18 15:13:10    阅读次数:266
POJ 1159 Palindrome DP
Palindrome Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 51913   Accepted: 17877 Description A palindrome is a symmetrical string, that is, a string read ide...
分类:其他好文   时间:2014-07-18 12:21:25    阅读次数:207
[LeetCode] Palindrome Partitioning
Given a strings, partitionssuch that every substring of the partition is a palindrome.Return all possible palindrome partitioning ofs.For example, giv...
分类:其他好文   时间:2014-07-18 12:12:12    阅读次数:222
[cc150] check palindrome of a singly linked list
Problem: Implement a function to check if a singly linked list is a palindrome.思路:最简单的方法是 Reverse and compare.另外一种非常经典的办法是用 Recursive 的思路,把一个list看成这种形...
分类:其他好文   时间:2014-07-16 17:41:23    阅读次数:188
[leetcode]Palindrome Partitioning
Palindrome PartitioningGiven a strings, partitionssuch that every substring of the partition is a palindrome.Return all possible palindrome partitioni...
分类:其他好文   时间:2014-07-16 17:41:15    阅读次数:173
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!