Search⌘ K
AI Features

Longest Palindrome Subsequence

Explore how to determine the longest palindromic subsequence in a given sequence by applying dynamic programming. Understand the recursive formulation and implement solutions that efficiently compute the subsequence length, preparing you for coding challenges and interviews.

We'll cover the following...

Problem statement

Given a sequence of characters, find the length of the longest palindromic subsequence in it.

For example, if the given sequence is BBABCBCAB, the output should be 7 as BABCBAB is the longest palindromic subsequence in it. A sequence is a palindromic sequence if that sequence reads the same backward as forwards, e.g. madam.

Note: For the given sequence BBABCBCAB, subsequence BBBBB and BBCBB are also palindromic subsequences, but these are not the longest. ...

Solution: Recursive