Use DP to calculate Palindrome first, more efficient, AC