Sonam Gupta lives few distance far from her boyfriend which is represented in the form of String, where 1 character represents 1 unit of distance. Your task is to help her by printing the maximum distance between she and her boyfriend. Given a String s (in lowerCase only). Starting from letter 'a' which is the only source. for example:- "aaabcahd..." . Now you can only jump from one character to another in the form that a to b; b to c; c to d and so on. You have to find the maximum distance from source to her boyfriend(destination). And if there is no place to jump on then print -1.
The first line of input contains an integer denoting the no of test cases. Then T test cases follow. Each test case contains single line String input.
For each test case in a new line print the maximum distance.
For first test case:
As 'a' will only jump to 'b' and maximum distance is 6.
For Second test case:
As 'a' will only jump to 'b' and 'b' will jump to 'c' and distance is 5.
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.