Manacher's Algorithm and AC Automaton: Linear-Time Palindromes and Multi-Pattern Matching
Manacher's Algorithm
Purpose
Manacher's algorithm computes the longest palindromic substring centered at each position (including positions between characters for even-length palindromes) in O(n) time complexity.
Naive Approach
The naive method examines each center position and attempts to expand outward character by character until the charact ...
Posted on Sat, 19 Sep 2026 16:16:48 +0000 by Mathy
Finding the Longest Palindromic Substring in Linear Time Using Manacher's Algorithm
Problem Statement
Given a string of length (n), find the length of the longest palindromic substring where (n \le 10^5).
Brute-Force Approach
A straightforward method involves iterating through each position as a potential center and expanding outward in both directions to check for palindromes. Taking the maximum length among all centers yield ...
Posted on Thu, 07 May 2026 03:39:19 +0000 by mdomel