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-29 18:43:56

@nitish rao, You are removing the leading zeros, you do not have to remove that. Exact number of digit should be printed.

praveen123: 2013-05-29 18:40:33

@evil_hack: you are printing an extra blank line in every test case. Remove that and enjoy :)

evil_hack: 2013-05-29 17:34:34

@praveen123 plz check my latest soln.... i cannot figure out any cases where it might be giving WA

evil_hack: 2013-05-29 17:33:20

@praveen123 I have check for 100's of input and I am getting correct answer.Can you please tell me what is the problem in my solution.

nitish rao: 2013-05-25 08:38:05

@praveen123 can you please jst check my solution and hint me of where i am going wrong... i was getting WA.. id:9350152..

edit:Thanks a million.. praveen123.. :) :)

Last edit: 2013-06-05 16:24:36
Ashish Lavania: 2013-05-02 06:48:14

@praveen123 plz check my latest soln.... i cannot figure out any cases where it might be giving WA

--> answer(by praveen123), Your code is not outputting anything in some test cases, For which there should be a output

thanks!!

Last edit: 2013-05-02 03:17:18
akash kumar: 2013-05-02 06:48:14

though it is giving wrong ans continously.. my solution code is 9025689.
---> (praveen123) I am editing your comment as you have got accepted , I think that your comment was giving some hints to the problem. I hope you won't mind :)

Last edit: 2013-04-04 13:26:30
majd gda: 2013-05-02 06:48:14

"if value of n is equal to k. then just print a new line."
is it "value of n" or "no of digits in n" ???
EDIT: no of digits in n

Last edit: 2013-03-31 04:27:30
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

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