Back to course home

0% completed

Longest Palindromic Subsequence

## Problem Statement

Given a sequence, find the length of its Longest Palindromic Subsequence (LPS). In a palindromic subsequence, elements read the same backward and forward.

A subsequence is a sequence that can be derived from another sequence by deleting some or no elements without changing the order of the remaining elements.

**Example 1:**

```
Input: "abdbca"
Output: 5
Explanation: LPS is "abdba".
```

**Example 2:**

```
Input: = "cddpd"
Output: 3
Explanation: LPS is "ddd".
```

**Example 3:**

```
Input: = "pqr"
Output: 1
Explanation: LPS could be "p", "q" or "r".
```

**Constraints:**

`1 <= st.length <= 1000`

`sy`

consists only of lowercase English letters.

## Try it yourself

Try solving this question here:

Python3

Python3

. . .

Mark as Completed