This question comes in varieties:
- Longest palindromic substring
- All palindromic substring
- Palindromic decomposition
alg. palindromic substring search.1
- Double Loop, on :
- DP:
- Manacher’s algorithm2
alg. Smallest Palindromic Decomposition. Homework Link
- run substring search (by any of above)
- run DP to get smallest decomposition
alg. Palindromic Subsequence search.3 Complicated much more by the fact that it’s a subsequence.
- A variant of Dynamic Programming
- Idea 1: run for every char
- Idea 2: ¶
bccab, we see is a subseq. We then consider the innerb + {inner} + band count the inner subseq.