Manacher's algorithm (algorithm to find longest palindrome substring in linear time)

前端 未结 10 523
走了就别回头了
走了就别回头了 2020-12-22 16:02

After spending about 6-8 hours trying to digest the Manacher\'s algorithm, I am ready to throw in the towel. But before I do, here is one last shot in the dark: can anyone e

10条回答
  •  失恋的感觉
    2020-12-22 16:37

    This material is of great help for me to understand it: http://solutionleetcode.blogspot.com/2013/07/leetcode-longest-palindromic-substring.html

    Define T as the length of the longest palindromic substrings centered at each of the characters.

    The key thing is, when smaller palindromes are completely embedded within the longer palindrome, T[i] should also be symmetric within the longer palindrome.

    Otherwise, we will have to compute T[i] from scratch, rather than induce from the symmetric left part.

提交回复
热议问题