Definition
A palindrome is any finite sequence that is identical to its own reversal. The word "racecar" reads the same from left to right and right to left; the number 121 has the same digits in forward and reverse order; the phrase "A man, a plan, a canal: Panama" (stripping spaces and punctuation) exhibits the same symmetry. The defining property is reversal invariance: the sequence is a fixed point of the reversal operation.
The term comes from the Greek palindromos — "running back again" — and the concept appears across domains that at first seem unrelated. In linguistics, palindromes are curiosities of word structure. In mathematics, palindromic numbers have properties studied in number theory, and the question of which numbers eventually produce palindromes under repeated "reverse and add" operations remains open. In computer science, palindrome detection is a standard exercise in algorithm design — checking whether a string is palindromic is a clean problem that illustrates two-pointer techniques, recursion, and dynamic programming.
Beyond the purely formal, palindromes are a concrete instance of a much broader idea: symmetry as a property that constrains and organises structure. A palindrome has a centre (or a pair of central characters) around which every element mirrors its counterpart. This bilateral symmetry connects palindromes to group theory, where the reversal operation generates a two-element group acting on sequences, and to information theory, where the palindrome constraint halves the degrees of freedom in the second half of a sequence given its first half.
Why it matters
How it works
Detection and the two-pointer technique
The canonical algorithmic question is: given a string, is it a palindrome? The naive approach compares every character to its mirror: character at position i must equal character at position n-1-i for all valid i. This can be done with two pointers starting at opposite ends and moving inward — if any pair mismatches, the string is not a palindrome; if the pointers meet or cross without a mismatch, it is.
This technique extends to a harder problem: finding the longest palindromic substring within a longer string. One approach expands outward from each possible center (each character, and each gap between characters); another uses Manacher's algorithm to find all palindromic substrings in linear time by exploiting the symmetry within palindromes found so far. Both approaches illustrate how structural properties of a class of objects — here, the nested mirror symmetry of palindromes — can be exploited algorithmically.
Palindromic numbers and number-theoretic questions
A number is palindromic in a given base if its digit representation reads the same forwards and backwards. 121, 9009, and 12321 are palindromes in base 10. Whether a number is palindromic is base-dependent: 10 is not a palindrome in base 10, but 5 (which is "101" in base 2) is a palindrome in binary.
The "reverse and add" procedure — take a number, reverse its digits, add the two — often produces a palindrome quickly. Starting from 57: 57 + 75 = 132, 132 + 231 = 363, which is palindromic after two steps. The Lychrel conjecture asserts that some numbers (196 being the most studied) never reach a palindrome under this procedure, regardless of how many steps are taken — no proof or counterexample has been found after decades of computation.
Where it goes next
Palindromes are an introduction to a family of ideas about symmetry and invariance. The deeper principle is that many important mathematical and physical properties can be characterised as invariance under some operation: palindromes under reversal, circles under rotation, conservation laws under time translation. Learning to look for what is preserved when something is transformed is one of the most productive habits in mathematical and scientific thinking.
In computer science, palindrome problems are a staging ground for dynamic programming — the problem of counting distinct palindromic subsequences, or the minimum insertions to make a string palindromic, are natural extensions that require the full machinery of optimal substructure and memoization.