Remove K Digits

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

Time Limit: 1.0 s

Memory Limit: 64.0 MB

Little Jack loves playing with numbers. Recently, he learned about programming and was super excited to find out that strings can represent really big numbers!

Now that Jack is mixing his love for numbers with his new programming skills, he has a fun challenge ahead. Given a large non-negative integer num represented as a string, he wants to remove exactly k digits from it. But there’s a catch—Jack wants the resulting number, after removing those digits, to be the largest possible.

Can you help Little Jack decide which digits he should remove to achieve the largest possible number?

Input format:

Input starts with \(T\) (\(T \le 100\)), the number of cases to check. For each case,

  • The first line contains 2 integers, \(N\) and \(k\) (\(0 \le k \le N \le 100\)), where \(N\) is the length of num, and \(k\) is the number of digits to be removed.
  • The second line contains the number num as a string.

Output format:

Print the largest possible number obtained after removing \(k\) digit.

Sample Input:

2
5 5
54231
5 2
54231

Sample Output:

0
543

Sylhet ICPC 2024 Collaborative Challenge: Episode 2

Not Attended
Status
Done
Rule
ACM/ICPC
Problem
9
Start at
2024-10-30 08:45
End at
2024-10-30 12:45
Duration
4.0 hour(s)
Host
Partic.
18