Back to the Problem
It equals the LCS of S and its reverse — reuse the LCS table.
Complexity: O(|S|2)