Files
dsa-competitive-programming/leetcode/lc5/notes.md
T
papyrus 192ce44a81 Add notes on palindrome algorithms
Added notes on palindrome algorithms including expand-around-center and Manacher's Algorithm.
2026-01-29 14:19:46 +05:30

7 lines
607 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
The expand-around-center approach checks every character (and every gap between characters) as a potential palindrome center and expands outward to verify palindromes, resulting in repeated character comparisons and a worst-case time complexity of O(n²).
In contrast, Manachers Algorithm optimizes this process by transforming the string and using palindrome symmetry to reuse previously computed information, thereby eliminating redundant expansions and achieving a linear time complexity of O(n).
in the code
C -> center of the rightmost palindrome
R -> right boundary of rightmost Palindrome