Manacher’s Algorithm Explained— Longest Palindromic Substring

Written by mithratalluri | Published 2020/11/07
Tech Story Tags: algorithms | problem-solving | data-structures | java | palindrome | mathematics-and-programming | mathematics | hackernoon-top-story

TLDR 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:via the TL;DR App

no story

Written by mithratalluri | Solving smaller problems today to solve bigger problems tomorrow!
Published by HackerNoon on 2020/11/07