题意是寻找一个字符串的最大回文字串,最简单的是n3方的算法,由于字符串最大长度为1000,所以这个方法很危险而且不科学。紧接着想到的是一个n方的算法:回文子串是从中间向两边产生的,那么对于每个字符考察这个字符往外的所有可能不就可以找到以这个字符为中心的最长回文子串了吗?当然要考虑偶数的情况,即那个中...
分类:
其他好文 时间:
2015-07-06 15:51:01
阅读次数:
106
题目:
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.
题意:
给定字符串S...
分类:
编程语言 时间:
2015-07-06 12:30:14
阅读次数:
115
public class Solution { public String longestPalindrome(String s) { //本题是动态规划思想,构造一个数组pal[i][j],表示从i到j是否为一个回文, //pal[i][j]=true;if i=...
分类:
其他好文 时间:
2015-07-04 22:14:37
阅读次数:
236
题目: 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 lo...
分类:
其他好文 时间:
2015-07-04 18:11:21
阅读次数:
119
原题链接:https://leetcode.com/problems/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 exis...
分类:
其他好文 时间:
2015-07-03 10:45:37
阅读次数:
146
题目:LeetCode 005 Longest Palindromic SubstringGiven a string S, find the longest palindromic substring in S. You may assume that the maximum length of ...
分类:
其他好文 时间:
2015-06-30 14:49:25
阅读次数:
108
用Manacher可以推出O(n)对相等和不等关系。将相等的用并查集维护,不等的连边。然后从1到n,如果该等价类还没被考虑过,则ans*=26-与它不等的考虑过的等价类个数。#include#include#define N 1000010int n,m,i,r,p,f[N>=1)==F(y>>=1...
分类:
其他好文 时间:
2015-06-22 19:17:55
阅读次数:
104
题目链接:http://acm.swust.edu.cn/problem/797/Time limit(ms): 1000 Memory limit(kb): 10000DescriptionPalindromes are numbers that read the same forwar...
分类:
其他好文 时间:
2015-06-22 14:47:51
阅读次数:
155
原题链接:https://leetcode.com/problems/longest-palindromic-substring/
Given a string S,
find the longest palindromic substring inS.
You may assume that the maximum length of S is
1000, and ther...
分类:
其他好文 时间:
2015-06-21 14:33:22
阅读次数:
119
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 longes...
分类:
其他好文 时间:
2015-06-20 22:00:33
阅读次数:
219