InterviewBit Academy is now Scaler!
InterviewBit Academy is now Scaler Academy!

Remove K Digits

Given a non-negative integer A represented as a string, remove B digits from the number so that the new number is the smallest possible.


  1. The length of A is less than 10002 and will be >= B.
  2. The given num does not contain any leading zero.

Input Format:

The first argument of input contains a string A, of length N.
The second argument of input contains the integer B.

Output Format:

Return a string representing the minimum possible number after removing B digits.


1 <= N <= 10002
0 <= S[i] <= 9


Input 1:
	A = "1432219"
	B = 3

Output 1:

Explanation 1:
	You can remove 4, 3 and one of the 2s.

Input 2:
	A = "10200"
	B = 1

Output 2:

Explanation 2:
	You can remove 1.

Input 3:
	A = "10"
	B = 2

Output 3:

Explanation 3:
	You can remove all the digits.
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt? Checkout Sample Codes for more details.
Start solving Remove K Digits on Interview Code Editor
Sign Up
to access hints and editorial solutions for Remove K Digits


Click here to start solving coding interview questions