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
No.1
Input:
“bbbab”
Output:
4
One possible longest palindromic subsequence is “bbbb”.
No. 2
Input:
“cbbd”
Output:
2
One possible longest palindromic subsequence is “bb”.
Code
1 | public int longestPalindromeSubseq(String s) { |