Longest Palindromic Substring DP way, but Memory Limit Exceeded error