$n \leq 500000$的01串,1跟0配,问最长回文子串。 $0=1$,$1 \neq 1$,$0 \neq 0$,然后二分哈希或manacher或回文树。 1 //#include<iostream> 2 #include<cstring> 3 #include<cstdio> 4 //# ...
分类:
其他好文 时间:
2018-04-28 14:34:02
阅读次数:
175
近期刷了好几次的oj,好受伤好多都是相似的题目。 最长回文子串 string preprocess(string &str) { string afterProcessStr="#"; for(int i=0;i<str.size();++i) { afterProcessStr += str.su ...
分类:
其他好文 时间:
2018-04-20 22:10:16
阅读次数:
221
给定一个字符串 s,找到 s 中最长的回文子串。你可以假设 s 长度最长为1000。 示例: 示例: class Solution {public: string longestPalindrome(string s) { if(s=="") return ""; int max=1; string ...
分类:
其他好文 时间:
2018-04-04 20:47:33
阅读次数:
121
https://www.lydsy.com/JudgeOnline/problem.php?id=2342 解法一: 对原串构建回文自动机 抽离fail树,从根开始dfs 设len[x]表示节点x表示的最长回文子串长度 在fail树上,x到根节点的路径上的点表示的字符串包含了x代表的回文子串的所有回 ...
分类:
其他好文 时间:
2018-04-01 21:50:07
阅读次数:
157
在计算机科学中,最长回文子串或最长对称因子问题是在一个字符串中查找一个最长连续子串,这个子串必须是回文。例如“banana”最长回文子串是“anana”。最长回文子串并不能保证是唯一的,例如,在字符串“abracadabra”,没有超过三的回文子串,但是有两个回文字串长度都是三,是“ada”和“ac ...
分类:
编程语言 时间:
2018-03-24 14:58:28
阅读次数:
244
题目中文:求最长回文子串 题目难度:Medium 题目内容: Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000. 翻译: ...
分类:
编程语言 时间:
2018-03-19 19:09:23
阅读次数:
224
部分正确(19分)代码: #include <stdio.h> #include <memory.h> #include <math.h> #include <string> #include <cstring> #include <vector> #include <set> #include < ...
分类:
其他好文 时间:
2018-03-15 13:18:13
阅读次数:
193
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. For example,"A man, a plan, a canal: Pan ...
分类:
其他好文 时间:
2018-03-13 10:22:02
阅读次数:
119
提出问题 最长回文子串问题 :给定一个字符串,求它的最长回文子串长度。 如果一个字符串正着读和反着读是一样的,那它就是回文串。如a、aa、aba、abba等。 暴力解法 简单粗暴:找到字符串的所有子串,遍历每一个子串以验证它们是否为回文串。一个子串由子串的起点和终点确定,对于一个长度为n的字符串,共 ...
分类:
编程语言 时间:
2018-03-08 15:55:47
阅读次数:
408
1、引言 最近在刷leetcode题的时候,遇到一个求最长回文子串的题目,于是,我写了如下的代码: class Solution(object): def longestPalindrome(self, s): """ :type s: str :rtype: str """ if len(s) < ...
分类:
其他好文 时间:
2018-03-08 14:12:04
阅读次数:
156