Increasing Sub Sequence
Submissions: 1316   Accuracy:

52.56%

  Difficulty: Easy   Marks: 2

Given a string which includes characters a, b, c, ..., z. Where value of a=1, b=2, ..., z=26. Now find the largest increasing sub sequence in the string and print it's length.

Note:  Sub sequence doesn't require elements to be consecutively increasing.

Input:
The first line contains a single integer T i.e. the number of test cases. The first and the only line of each test case consists of a string S.


Output:
In one line print the length of the largest increasing sub sequence in the string.


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

 

Examples:
Input:

2
pcbhdbjcvhjsdjhvczvd
abcdapzfqh

Output:
7
6

Explanation:
Test Case 2:
The length of largest increasing subsequence is 6. One of the sequence with max length 6 is a, b, c, d, p, z. 

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

Contributor: Saksham Ashtputre
Author: saksham0751


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.