Skip to content

Palindrome Partition

Step 1

We notice that \(T_1\) and \(T_{2k}\) are a pair of borders of \(S\). If we interleave \(S\) like: \(S_1, S_{2k}, S_2, S_{2k-1}, \dots\), then we basically have to partition the the new string \(S\) into any number of even palindromes.

Step 2

We have the dp:

$\(f[i] = \sum_{\substack{j-i \equiv 0 \pmod{2} \\ s[j+1,i] \text{ is a palindrome}}}{f[j]}\)$ optimize with main result of border theory