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
CKA: 2013-05-29 19:07:56

http://ideone.com/d2N8g4
i suppose solution should time out .but why its giving WA
please help

Last edit: 2013-05-29 19:08:20
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
Shubham Rai: 2013-05-17 18:10:39

Last edit: 2013-05-21 09:51:24
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

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