longest palindromic substring: dp, O(n^2) space