Longest Palindromic Substring, dynamic programming method