Longest Palindromic Subsequence
Submissions: 16131   Accuracy:

44.59%

  Difficulty: Easy   Marks: 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

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Saksham Raj Seth
Author: saksham seth


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.


to report an issue on this page.