Skip to content
StackDecode
StringsExplained

Manacher's Algorithm

Find every palindromic radius in linear time by reusing mirrored results.

Time

O(n)

Extra space

O(n)

Use it for

Longest palindromic substring in O(n).

An animated walkthrough for this algorithm isn’t built yet. The summary above explains the idea; see the related animated algorithms below to practise the same technique.