Want to solve this problem? Login now to get access to solve the problems

Problem

Submissions

Solution

Leaderboard

Coming soon

0

Difficulty: HARD

Avg. time to solve

45 min

Success Rate

50%

Problem Statement

Suggest Edit

```
The first line of input contains an integer ‘T’ representing the number of test cases. Then the test cases follow.
The only line of each test case contains a single string A consisting of only lowercase English letters.
```

```
For each test case, print a single integer denoting the length of longest palindromic subsequence in string A.
The output for each test case is in a separate line.
```

```
You do not need to print anything; it has already been taken care of.
```

```
1 <= T <= 10
1 <= N <= 100
Where ‘T’ is the number of test cases, and ‘N’ is the length of the string.
```

```
2
bbabcbcab
bbbab
```

```
7
4
```

```
For the first test case, the longest palindromic subsequence is “babcbab”, which has a length of 7. “bbbbb” and “bbcbb” are also palindromic subsequences of the given string, but not the longest one.
For the second test case, the longest palindromic subsequence is “bbbb”, which has a length of 4.
```

```
3
cbbd
bebeeed
abcd
```

```
2
4
1
```

Want to solve this problem? Login now to get access to solve the problems