paint-brush
Manacher’s Algorithm Explained— Longest Palindromic Substringby@mithratalluri
13,842 reads
13,842 reads

Manacher’s Algorithm Explained— Longest Palindromic Substring

by Mithra TalluriNovember 7th, 2020
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Manacher’s Algorithm helps us find the longest palindromic substring in the given string. It optimizes over the brute force solution by using some insights into how Palindromes work. When we move i from left to right, we try to “expand” the palindrome at each i. This is exactly where Manacher's algorithm optimizes better than brute force. The answer for a given string is 9 when the Palindrome is centered at index 5; c, l, and r are as follows:
featured image - Manacher’s Algorithm Explained— Longest Palindromic Substring
Mithra Talluri HackerNoon profile picture
Mithra Talluri

Mithra Talluri

@mithratalluri

L O A D I N G
. . . comments & more!

About Author

Mithra Talluri HackerNoon profile picture
Mithra Talluri@mithratalluri

TOPICS

THIS ARTICLE WAS FEATURED IN...

Permanent on Arweave
Read on Terminal Reader
Read this story in a terminal
 Terminal
Read this story w/o Javascript
Read this story w/o Javascript
 Lite