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.

agness | 122 |

aman1931998 | 102 |

Survivor | 100 |

uchitnitk | 96 |

lonecoder | 95 |

KshatriyaYash | 1066 |

nikhil_sojan | 1032 |

lonecoder | 1030 |

mazumderrohit8 | 899 |

SumitSingh27 | 832 |

blackshadows | 5327 |

Ibrahim Nash | 5215 |

akhayrutdinov | 5111 |

mb1973 | 4492 |

Quandray | 4444 |

Login to report an issue on this page.