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
ssvarma: 2018-06-24 14:55:45

@praveen123:hi! can u pls tell me where i m lacking in my code 21889739

sameer Hussain: 2016-11-16 12:18:47

I am getting TLE, if I use segment tree, for finding out next maximum character.

Can you please tell me where I going wrong here.??

hazem_khaled8: 2015-09-01 17:23:12

how can i avoid tle? (15041280)
http://www.spoj.com/status/hazem_khaled8/#

CoNtRaDiCtIoN: 2015-05-26 08:17:31

@praveen123 lots of wa can u pls provide some test cases where my solution fails or u can look into my code and tell the probable bugs... Thanks in advance :)

Ankit: 2015-04-25 15:27:42

Last edit: 2015-04-26 07:53:47
sahil hindwani: 2014-12-20 21:12:39

submission id :13224845 why is it giving wrong answer
can any one plsss provide me with the test cases at which my code is failing

Sudharsansai: 2014-12-11 19:09:07

Nice Problem!

$seraph$: 2014-10-03 05:49:14

@praveen123: Hi! can u pls tell me where i m lacking in my code 12526342.

SHASHANK PAL: 2014-08-30 10:45:27

Last edit: 2014-08-30 11:02:30
Rishav Goyal: 2014-08-04 13:23:51

Last edit: 2014-08-06 07:20:27

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