Approach Summary
Expand around each center. Track the longest expansion found. Returns the actual substring, not just the length.
How to Recognize This Pattern
- "Find the longest palindrome"
- Expand-around-center beats O(n²) DP space-wise
Complexity Analysis
Time Complexity
O(n²)
Space Complexity
O(1)
Tags
String Dynamic Programming