Error:
I thought it is DP, but I do not it is such stright forward: it just keep track how many Palindromic. The pattern is:
for(i = n - 1; i >= 0; i--)
for(j = i; j < n; j++)
dp[i][j] = s[i] == s[j]
&& (j - i <= 2 || dp[i + 1][j - 1] == true)
update:
remember the two loop, how to write it.
for i, we loop from tail to head, and for each j, go though forward