I am kind of confused of the first example, which says "bbbab"'s longest palindromic subsequence is "bbbb". Is this a typo or I didn't get the point?
Thanks in advance!
Check the link here.
I think the problem should state that find a substring which "contains" the longest palindromic sequence.
"abxba", "abyba" and "abzba" are the longest palindromic sequence which is in the substring "abxyzba".
Therefore, the returning answer should be the length of "abxba" which is 5.