Largest Number

2.3

18 votes
, Basic Programming, C++
Problem

Given an integer N which has D digits. You have to delete exactly K digits in integer N.

Find out the largest possible number which can be built from N after removing exactly K digits.

Input Format:

  • First line contains two space separated integers N K.

Output Format:

Print the largest possible number which can be built from N after removing exactly K digits.

Constraints:

1N10181K3KD

Sample Input
3412 1
Sample Output
412
Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

After removing exactly 1 digit, we can make

  • 412
  • 312
  • 342
  • 341

Among, them 412 is the largest possible number.

Editor Image

?