Determine whether an integer is a palindrome. Do this without extra space.Some hints:Could negative integers be palindromes? (ie, -1)If you are thinki...
分类:
其他好文 时间:
2015-02-04 23:17:55
阅读次数:
162
Given a strings, partitionssuch that every substring of the partition is a palindrome.Return the minimum cuts needed for a palindrome partitioning ofs...
分类:
其他好文 时间:
2015-02-04 12:36:35
阅读次数:
104
Given a string s, partition s such that every substring of the partition is a palindrome.Return the minimum cuts needed for a palindrome partitioning ...
分类:
其他好文 时间:
2015-02-04 07:05:10
阅读次数:
215
Given a string s, partition s such that every substring of the partition is a palindrome.
Return the minimum cuts needed for a palindrome partitioning of s.
For example, given s = "aab",
Retu...
分类:
其他好文 时间:
2015-02-03 21:27:35
阅读次数:
196
Given a string s, partition s such that every substring of the partition is a palindrome.
Return all possible palindrome partitioning of s.
For example, given s = "aab",
Return
[
["aa","...
分类:
其他好文 时间:
2015-02-03 15:09:45
阅读次数:
96
原题地址方法I:传统的判断回文的方法,左右指针,不断收缩判断方法II:将数字翻转,判断翻转后的数字是否相等,溢出也没关系因为溢出以后更加不可能相等了代码(方法II): 1 bool isPalindrome(int x) { 2 int oldx = x; 3 int...
分类:
其他好文 时间:
2015-02-02 17:26:42
阅读次数:
140
原题地址isalnum:判断是否是字符或数字toupper:将字符转换成大写,非字符不变代码: 1 bool isPalindrome(string s) { 2 string news; 3 for (auto c : s) 4 if (is...
分类:
其他好文 时间:
2015-02-02 17:20:32
阅读次数:
137
/*
最少需要补充的字母数 = 原序列S的长度 — S和S'的最长公共子串长度
*/
# include
# include
# include
# include
using namespace std;
int dp[2][5010];///滚动数组
int main()
{
char a[5010];
char b[5010];
int i,j,k,len;...
分类:
编程语言 时间:
2015-02-02 16:01:38
阅读次数:
168
原题地址因为要找所有的解,只能搜索+回溯了看来数据量比较小,关于回文串的判断没有使用动态规划也可以过代码: 1 vector > res; 2 3 bool palindromep(string s) { 4 int i = 0; 5 int j = s.length() - 1; 6 ...
分类:
其他好文 时间:
2015-02-01 23:02:53
阅读次数:
169
链接:click here
题意:
给你一串字符串,让你求最少加入几个字符,才能使得这个字符串是个回文串。
思路:
设a[i]是这个字符串,b[i]是这个字符串的逆序串。那么a[i],b[i]的最长公共子序列就是所求的字符串里拥有的最大的回文串。然后用总串长减去最大的回文串长度即为所求。求最长公共子序列的公式为:dp[i][j]=max(dp[i-1] [j],dp[i][j-1]...
分类:
编程语言 时间:
2015-01-31 23:22:48
阅读次数:
461