Given a string s, find the longest palindromic subsequence's length in s. You may assume that the maximum length of s is 1000.
Example 1:
Input:
"bbbab"
Output:
4
One possible longest palindromic subsequence is "bbbb".
题意:
找出给定字符串中的最长回文子序列
Solution1: DP
1. state: dp[i][j] stands for the length of longest panlin subsequences in substring[i,j] inclusively
2. function:
if s[i] = s[j] , dp[i][j] = dp[i+1][j-1] + 2
if s[i] != s[j], dp[i][j] = MAX(d[i+1][j] , dp[i][j-1])
code