求最长回文子串的裸题,搞竞赛的时候遇到过各种花样的变式。
n方的朴素算法已经烂大街了,推荐使用O(n)的算法,只可惜很久没用过manacher算法,不会写了,所以花了一段时间温故知新。
manacher算法原理不了解的道友可以看这篇文章:...
分类:
其他好文 时间:
2016-08-24 15:54:14
阅读次数:
167
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 ...
分类:
其他好文 时间:
2016-08-24 06:35:43
阅读次数:
197
Gym 101047B Renzo and the palindromic decoration Time Limit:2000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Practice Gym 101047B Renzo and t ...
分类:
其他好文 时间:
2016-08-22 21:35:01
阅读次数:
123
A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. Find the largest ...
分类:
其他好文 时间:
2016-08-22 18:16:49
阅读次数:
165
UNIMODAL PALINDROMIC DECOMPOSITIONS Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 5430 Accepted: 2641 Description A sequence of positive ...
分类:
其他好文 时间:
2016-08-22 12:39:17
阅读次数:
302
原题如下: 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 ...
分类:
其他好文 时间:
2016-08-15 18:59:55
阅读次数:
146
https://leetcode.com/problems/longest-palindromic-substring/ 题目:求字符串最长回文串。 第一种思路:以每一个字符为回文串中间的字符时,最长的回文串。考虑回文串字符个数为奇数,偶数的2种情况。 x--,j++ 的向两边扩展,判断最长的回文串 ...
分类:
其他好文 时间:
2016-08-13 21:08:35
阅读次数:
113
这道题的关键点在于,对于字符串的赋值操作要谨慎,尽量采用记录下标的方式,而不是整个字符串的赋值,这样可以节省时间。 ...
分类:
其他好文 时间:
2016-08-09 18:51:00
阅读次数:
149
这道题是比较常考的题目,求回文子串,一般有两种方法。 第一种方法比较直接,实现起来比较容易理解。基本思路是对于每个子串的中心(可以是一个字符,或者是两个字符的间隙,比如串abc,中心可以是a,b,c,或者是ab的间隙,bc的间隙)往两边同时进行扫描,直到不是回文串为止。假设字符串的长度为n,那么中心 ...
分类:
其他好文 时间:
2016-07-21 00:35:38
阅读次数:
152