strings.manacher¶
Functions¶
|
Module Contents¶
- strings.manacher.palindromic_string(input_string: str) str ¶
>>> palindromic_string('abbbaba') 'abbba' >>> palindromic_string('ababa') 'ababa'
Manacher’s algorithm which finds Longest palindromic Substring in linear time.
- first this convert input_string(“xyx”) into new_string(“x|y|x”) where odd
positions are actual input characters.
- for each character in new_string it find corresponding length and
store the length and left,right to store previously calculated info. (please look the explanation for details)
return corresponding output_string by removing all “|”