Problem of the day
Consider string ‘Str’ = “abba”, then its substring in lexicographical order is [“a”, “ab”, “abb”, “abba”, “b”, “bb”, “bba”]. Clearly, the last substring in lexicographical order is “bba”.
The first line of input contains an integer ‘T’ denoting the number of test cases, then ‘T’ test cases follow.
The first and only line of each test case consists string ‘Str’
For each test case, in a separate line print the last substring of ‘Str’ in lexicographical order.
You do not need to print anything, it has already been taken care of. Just implement the given function.
1 <= T <= 50
1 <= N <= 10^4
‘Str’ contains only lowercase English letters.
Time limit: 1 sec