Apex › Storage & databases

Manacher's algorithm — longest palindrome in O(n)

Find the longest palindromic substring in linear time. The idea: interleave separators so even and odd palindromes look alike, then give every position a radius — and reuse the radii that mirror symmetry already guarantees, so new character comparisons only ever push the frontier right. Type a string and watch the radius bars and the palindrome it picks.

More in Storage & databases