Problem A. Deleting Character
Description
You have a string consists of N characters, you want to make a new string by deleting one of the characters from the original string. In which way you can make a string with the largest lexicographic order. Lexicographic order is defined as below:
Comparing string A and string B, you should start from the first characters of them, if A[0]>B[0] then A is lexicographically larger than B, vice versa. But if A[0]==B[0], you should take into the next characters them, comparing A[1] and A[1] and so on. Notice that string "ab" is lexicographically smaller than string "abc".
Input
The first line is a number T which indicates the number of test cases.
For each test case there is a number N (1<=N<=100000) which indicates the length of the string and the following line is the input string.
Output
For each test case output a string which is lexicographically largest.
Sample Input
2
3
abc
5
power
Sample Output
bc
pwer
Hint
String “abc” can transfer into “bc”, “ac” and “ab”, and “bc” has the largest lexicographic order.
题意:给一个字符串,删掉一个字符,求删掉一个字符后的字典序最大的字符串,输出。
是个签到题,然而我没过。
从前到后枚举,找出第一个比后一位字符小的字符。
我做成了找出一个比前面小而且比后面小的字符。呵呵