#C10493. Largest Lexicographical Substring After Deletion
Largest Lexicographical Substring After Deletion
Largest Lexicographical Substring After Deletion
You are given an integer \(T\) denoting the number of test cases. For each test case, you are provided a string \(S\). Your task is to remove exactly one character from \(S\) to form a new string. Out of all possible resulting strings, you must choose the one that is largest in lexicographical order.
In other words, for a string \(S\) of length \(n\), you need to compute \[ \text{result} = \max_{0 \leq i < n} \; \big(S[0:i] + S[i+1:n]\big), \] where the maximum is taken in lexicographical order.
Print the answer for each test case on a separate line.
inputFormat
The first line of input contains an integer \(T\) representing the number of test cases.
Each of the following \(T\) lines contains a non-empty string \(S\) consisting of lowercase English letters.
outputFormat
For each test case, output a single line containing the largest lexicographical substring that can be obtained by deleting exactly one character from \(S\).
## sample2
abcde
ahbgdc
bcde
hbgdc
</p>