第一种方法是DFS,将所有可能的前缀找到,递归调用partition(剩余字符串)
复杂度为O(2^n)
代码如下:
vector> partition(string s) {
vector> res;
vector patition;
if (s.size() == 0) return res;
partition(s...
分类:
其他好文 时间:
2014-10-10 01:33:23
阅读次数:
464
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...
分类:
其他好文 时间:
2014-10-07 19:09:53
阅读次数:
180
Problem A
Make Palindrome
Input: standard input
Output: standard output
Time Limit: 8 seconds
By definition palindrome is a string which is not changed when reversed. "MADAM" is a nice example...
分类:
其他好文 时间:
2014-10-07 12:44:13
阅读次数:
176
[问题描述]Given a strings, partitionssuch that every substring of the partition is a palindrome.Return the minimum cuts needed for a palindrome partitioni...
分类:
其他好文 时间:
2014-10-07 01:23:32
阅读次数:
341
谋事在人,成事在天[问题描述]Given a strings, partitionssuch that every substring of the partition is a palindrome.Return all possible palindrome partitioning ofs.F...
分类:
其他好文 时间:
2014-10-07 00:28:22
阅读次数:
232
[leetcode]Given a string s, partition s such that every substring of the partition is a palindrome....
分类:
其他好文 时间:
2014-10-06 12:19:50
阅读次数:
200
【leetcode】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....
分类:
其他好文 时间:
2014-10-06 12:12:00
阅读次数:
149
题目大意:给出一个字符串,问至少添加多少个字符才能使它成为回文串?思路:很明显的方程是:dp[i][j]=min{dp[i+1][j],dp[i][j-1],dp[i+1][j-1](str[i]==str[j]时)}dp[i][j]表示第i个字符到第j个字符构造成回文串最少添加的字符,但discu...
分类:
其他好文 时间:
2014-10-05 14:40:18
阅读次数:
188
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.
面DP题的考官都是神经病。。(吐...
分类:
其他好文 时间:
2014-10-01 13:15:31
阅读次数:
242
[Leetcode 题解]:Palindrome Number
分类:
其他好文 时间:
2014-09-30 18:53:39
阅读次数:
157