تمرین ریاضیات گسسته

Algorithms / Palindrome Manacher Lite

Least You Need to Know: Palindrome Centers, Symmetry, and Manacher-Lite Intuition

Palindrome reasoning starts from centers and symmetry. Manacher's algorithm pushes that idea further by reusing information from the current rightmost palindrome to compute all palindrome radii in linear time.

The least you need to know

Key notation

center middle point around which a palindrome is symmetric
radius how far a palindrome extends from its center
mirror reflected center inside the current known palindrome window

Tiny worked example

  • In `racecar`, the center is `e` and expansion matches characters symmetrically outward.
  • If you already know a long palindrome window, a mirrored center inside that window inherits a lower bound on its radius.
  • Manacher uses that reuse to skip repeated comparisons.
  • The same center idea handles both odd and even palindromes with the right representation.

Common mistakes

How to recognize this kind of problem

Start practice