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 : no of test cases <= 10^3

1 <= no 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: no of test cases

T line follow

every line has

n , 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

@amit jain: try some random small cases. You would find the error. Even in the case of only 1/2 removal.

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

@praveen123-thanx for your reply,but i am unable to fix the issue.For removing that random character,I am printing all characters only when in between '0' and '9'..still getting wrong answer.ID--8900709
Are there unnecessary digits in the output??

Last edit: 2013-03-15 18:21:24
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
Amit Jain: 2013-05-02 06:48:14

Last edit: 2013-03-14 09:04:23
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

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