2015校赛A

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.

题意:给一个字符串,删掉一个字符,求删掉一个字符后的字典序最大的字符串,输出。

是个签到题,然而我没过。

从前到后枚举,找出第一个比后一位字符小的字符。

我做成了找出一个比前面小而且比后面小的字符。呵呵

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值