Longest Palindromic Subsequence
Easy Accuracy: 44.59% Submissions: 22189 Points: 2

Given a String, find the longest palindromic subsequence

Input:
The first line of input contains an integer T, denoting no of test cases. The only line of each test case consists of a string S(only lowercase)


Output:
Print the Maximum length possible for palindromic subsequence.


Constraints:
1<=T<=100
1<=|Length of String|<=1000

 

Examples:
Input:

2
bbabcbcab
abbaab
Output:
7
4

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.

Output Window