|
| 1 | +Given a sequence, find the length and string of the longest palindromic subsequence in it. |
| 2 | + |
| 3 | +Example, if the given sequence is "BBABCBCAB", then the output should be 7 as "BABCBAB" is the longest palindromic subsequence in it. |
| 4 | +"BBBBB" and "BBCBB" are also palindromic subsequences of the given sequence, but not the longest ones. |
| 5 | + |
| 6 | +The naive solution for this problem is to generate all subsequences of the given sequence and find the longest palindromic subsequence. |
| 7 | +This solution is exponential in term of time complexity. Let us see how this problem possesses both important properties of a Dynamic Programming (DP) |
| 8 | +Problem and can efficiently be solved using Dynamic Programming. |
0 commit comments