MAX_NUM - finding maximum possible number

no tags 

Given a number n, Find out what max possible number you can make by deleting exactly k digits.

T : number of test cases <= 10^3.

1 <= number of digits in n <= 10^5. (n might contain leading zeros.)

0 <= k <= n

if value of n is equal to k. then just print a new line.

Input

T: number of test cases.

T lines follow each with n and k.

Output

max possible number.

Example

Input:
2
1223 2
8756 2

Output:
23
87

Explanation

Note that left to right order should be maintained. As in the example given answer is 23 not 32.


hide comments
praveen123: 2013-05-02 06:48:14

some random character is getting printed in the output. Rest seems fine.

Amit Jain: 2013-05-02 06:48:14

getting wrong answer again and again-ID-8890646..working fine for gievn test cases...can u please help me know some cases where my code fails?

Last edit: 2013-03-14 17:36:52
Orchid: 2013-05-02 06:48:14

@praveen123 my email id is orchidmajumder@gmail.com..please send..and i;m also trying to modify my approach..

Ashish Lavania: 2013-05-02 06:48:14

@praveen123 : O(n+k) soln not working.... TLE!

Adhityaa: 2013-05-02 06:48:14

Output is :
23

87

Or:
23
87

EDIT(praveen123) : second one, You can even see by copy pasting the test case on some text file.

Last edit: 2013-03-03 22:31:46
praveen123: 2013-05-02 06:48:14

@Orchid Majumder : give me your email id , So that I could give you largest test case, If there is any other way of helping you out, I will be happy to do that.

Orchid: 2013-05-02 06:48:14

@praveen123 : on my machine for a 99999 char input array both n and k it takes 0.072 seconds.

Last edit: 2013-03-01 17:45:25
praveen123: 2013-05-02 06:48:14

@Orchid Majumder : try largest test. You can generate values randomly and check your how much time it takes on your pc.

Orchid: 2013-05-02 06:48:14

@praveen123, ID -8809360 ,getting TLE on judge no 3 ..any hint about any further optimization??

brahim: 2013-05-02 06:48:14

Hello, is it possible to have a hint on submission id 8756377?
thx
Found the bug.

Last edit: 2013-02-21 15:02:25

Added by:praveen123
Date:2013-02-09
Time limit:0.407s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:general