Given a string s, return the length of the longest subsequence of s that is also a palindrome. Pattern focus: Longest palindromic subsequence. This is the canonical 2D DP palindromic subsequence problem.
s = input string
length of the longest palindromic subsequence
Example 1:
Input:
s = "bbbab"
Output:
4
Explanation:
One longest palindromic subsequence is bbbb.
Example 2:
Input:
s = "cbbd"
Output:
2
Explanation:
The subsequence bb is the longest palindrome.