Content deleted Content added
Kentzo2018 (talk | contribs) m Expand the explanation of why S' is needed in the Manacher's algorithm Tag: Reverted |
|||
Line 63:
Longest_Palindrome(string S, string S') {
//
//
// an odd-length string S' can be created from S
// by inserting a distinct character (e.g. '|')
// at the start, at the end as well as between all
// characters of S:
// - odd-length S gets even number of '|', thus S' remains odd-length
// - even-length S gets odd number of '|', thus S' becomes odd-length
// A palindrome in S remains a palindrome in S' and
// extra characters in S' can be trivially accounted for.
// The radius of the longest palindrome centered on each place in S'
|