Manacher
文章平均质量分 89
风遥~
这个作者很懒,什么都没留下…
展开
-
马 拉 车 模板题
1.题目引入:Andy the smart computer science student was attending an algorithms class when the professor asked the students a simple question, "Can you propose an efficient algorithm to find the length of the largest palindrome in a string?"A string is s.原创 2021-10-10 09:27:44 · 348 阅读 · 0 评论 -
Manacher (马拉车)算法
Manacher于1975年发现了一种线性时间算法,可以在列出给定字符串中从任意位置开始的所有回文子串。同样的算法也可以在任意位置查找全部极大回文子串,并且时间复杂度是线性的。那他是怎样实现的呢,别着急继续往下看。我们先看一下回文串,回文串有两种形式,一种是奇数的比如"aba",一种是偶数的比如"abba"。这里使用Manacher算法的时候,会在每个字符之间都会插入一个特殊字符,并且两边也会插入,这个特殊字符要保证不能是原字符串中的字符,这样无论原来字符串长度是奇数还是偶数,添加之后长度都原创 2021-08-25 11:25:46 · 651 阅读 · 0 评论