Palindrome Substrings Visualization & Animation

Counts all palindromic substrings by expanding around each center; O(n²) time, O(1) space.

## What is it? Count all palindromic substrings in a given string. Each character and each pair of consecutive identical characters can serve as a center from which you expand outward to find palindromes. ## How it works **Expand Around Center:** - For each index `i` (and each pair `i, i+1`), try to expand outward while `str[left] == str[right]` - Count each valid expansion as one palindromic substring - Total centers = `2n - 1` (n odd centers + n-1 even centers) ## When to use - Counting or listing all palindromic substrings - As a building block for "Longest Palindromic Substring" (return length instead of count) - Problems involving substring palindromes ## Key Points - O(n²) time — n centers, each expanded up to O(n) times - O(1) space — no auxiliary structures needed - Manacher's algorithm solves this in O(n) time, but expand-around-center is the standard interview approach

Category: algorithms

Difficulty: intermediate

Time Complexity: O(n²)

Space Complexity: O(1)

Palindrome Substrings

intermediate

Counts all palindromic substrings by expanding around each center; O(n²) time, O(1) space.

PhaseInit
Center[0]
Count0
L
R
a
[0]
b
[1]
b
[2]
a
[3]
e
[4]
a
[5]
e
[6]
center
Input: "abbaeae" (lowercased). Expand Around Center — check every position as palindrome center.