求最长回文串。把原串翻转后,加在原串后面,中间插入一个辨别字符。然后求SA,Height。然后枚举每个字母作为回文串中心,分长度为奇数和偶数去讨论:奇数求 suffix(i)和suffix(n-i+1)的最长公共前缀,偶数则求suffix(i)和suffix(n-i+2)(当然,i=1时不成立) 。...
分类:
其他好文 时间:
2014-12-16 22:30:39
阅读次数:
248
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","...
分类:
其他好文 时间:
2014-12-15 21:52:33
阅读次数:
145
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",
Return...
分类:
其他好文 时间:
2014-12-15 21:50:08
阅读次数:
172
Determine whether an integer is a palindrome. Do this without extra space.
思路:想办法把第一个和最后一个数字剥离出来比较
#include
int isPalindrome(int x){
int d=x/10,i=1;
int begin=0,end=0;
if(x<0) return 0...
分类:
其他好文 时间:
2014-12-15 17:22:08
阅读次数:
121
Determine whether an integer is a palindrome. Do this without extra space.
click to show spoilers.
Some hints:
Could negative integers be palindromes? (ie, -1)
If you are thinking of convertin...
分类:
其他好文 时间:
2014-12-15 09:03:15
阅读次数:
154
题目解题步骤对字符串进行处理,字符小写,去掉多余标点。对空字符串的情况进行判断。建立一个新的字符串对象,存入原字符串翻转后的结果如果这两个字符串相等,那么返回True,否则,返回False。我的答案第1版:class Solution: # @param s, a string # @return ...
分类:
移动开发 时间:
2014-12-13 17:52:21
阅读次数:
221
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 ...
分类:
其他好文 时间:
2014-12-12 06:44:13
阅读次数:
201
题目和上题一样leetcode Palindrome Partitioning,这里需要求的是最小的分割数,也就是上一题的所有可能里面最少的一个分割。例如:For example, givens="aab",Return1since the palindrome partitioning["aa",...
分类:
其他好文 时间:
2014-12-10 00:20:54
阅读次数:
334
Palindrome
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 3281 Accepted Submission(s): 1136
Problem Description
A palindrome is a s...
分类:
其他好文 时间:
2014-12-09 19:43:54
阅读次数:
158
Palindrome
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 3276 Accepted Submission(s): 1134
Problem Description
A palindrome is a s...
分类:
编程语言 时间:
2014-12-09 14:06:34
阅读次数:
228