how to find longest palindromic subsequence?
This can be solved in O(n^2) using dynamic programming. Basically, the problem is about building the longest palindromic subsequence in x[i…j] using the longest subsequence for x[i+1…j], x[i,…j-1] and x[i+1,…,j-1] (if first and last letters are the same). Firstly, the empty string and a single character string is trivially a palindrome. Notice that for a … Read more