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.

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.

_Shubham_Jain_06 | 399 |

maggiiiii | 306 |

Savage_19 | 284 |

ritikdagar0203 | 241 |

thanuvinu94 | 217 |

Bishnu Dev Panda | 810 |

_Shubham_Jain_06 | 710 |

okayboss | 593 |

maggiiiii | 589 |

Anugrah_kumar | 562 |

blackshadows | 5331 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4925 |

Quandray | 4547 |

Login to report an issue on this page.