原题地址最初的想法是用动态规划,令palin[i][j]表示s[i..j]是否是回文串,则有递推公式palin[i][j] = s[i] == s[j] && palin[i+1][j-1]。因为递推式只使用相邻层的值,所以编码的时候可以将二维状态数组压缩成一维的。代码: 1 string long...
分类:
其他好文 时间:
2015-01-30 17:03:05
阅读次数:
105
A number that will be the same when it is written forwards or backwards is known as a Palindromic Number. For example, 1234321 is a palindromic number...
分类:
其他好文 时间:
2015-01-28 14:24:46
阅读次数:
110
题目链接: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 palindromic ...
分类:
其他好文 时间:
2015-01-27 23:35:02
阅读次数:
144
描述:
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 palindromic substring.
思路:
刚开始非常天...
分类:
其他好文 时间:
2015-01-27 20:21:30
阅读次数:
205
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 palindromic substring.(最长回文子串)
中心扩展法:
pub...
分类:
其他好文 时间:
2015-01-27 18:31:08
阅读次数:
151
题目: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 palindromic substring.
下面是英文,祝你好运
...
分类:
其他好文 时间:
2015-01-27 16:35:09
阅读次数:
363
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 palindromic substring.
#include
#includ...
分类:
其他好文 时间:
2015-01-27 15:02:38
阅读次数:
164
Largest palindrome product
Problem 4
A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99.
Find the largest p...
分类:
编程语言 时间:
2015-01-27 09:34:40
阅读次数:
223
Given a stringS, find the longest palindromic substring inS. You may assume that the maximum length ofSis 1000, and there exists one unique longest pa...
分类:
其他好文 时间:
2015-01-25 11:03:14
阅读次数:
129
原题地址以前可以用DP枚举所有回文串,但是Leetcode后来增加了几组大数据,用DP会超时。什么!用DP都超时了??那怎么办?答:二分法尝试可能的回文串长度,直到找到最大值需要注意的是,假设现在已经验证了长度为length的回文串不存在,传统的二分法就会去尝试长度为length/2的回文串是否存在...
分类:
其他好文 时间:
2015-01-24 19:57:26
阅读次数:
127