Overview
Manacher's Algorithm inserts sentinel separators between characters so even- and odd-length palindromes share uniform centers, then maintains the rightmost palindrome boundary to mirror previously computed radii in O(n) time.
Finds the longest palindromic substring of any string in linear O(n) time by reusing palindrome radii across center reflections.
Compact metadata for implementation and discovery.
Manacher's Algorithm inserts sentinel separators between characters so even- and odd-length palindromes share uniform centers, then maintains the rightmost palindrome boundary to mirror previously computed radii in O(n) time.
Quick facts
Runtime and memory behavior at a glance.
Best
O(n)
Average
O(n)
Worst
O(n)
Space
O(n)
Interactive Runtime & Memory Budget Calculator
Estimate wall-clock latency, operation count, and working memory for Manacher's Algorithm across input scales.
428.6 µs
428.6 µs
1.53 MB
mirror(i) = 2C - iReflects position i across the current palindrome center C.
P[i] >= min(R - i, P[2C - i]) for i < RReuses the mirrored palindrome radius bounded by the rightmost palindrome edge R.
This entry is part of the 1,000-algorithm concept catalog and provides high-level pseudocode, complexity bounds, and relationship links rather than a standalone in-browser benchmark engine.
Structured Execution Steps
Finds the longest palindromic substring of any string in linear O(n) time by reusing palindrome radii across center reflections.
What each reference supports for this entry.
Original JACM paper introducing linear-time palindrome radius mirroring.
Open sourceGood next jumps from the relationship graph, ranked for useful discovery.
Both maintain a rightmost matched interval [L, R] to reuse prior comparisons in O(n) time.
Manacher's algorithm specializes in linear-time palindrome radii with minimal overhead.