Remove_k _ Digits

Given a number represented by string A of length N and an integer B.

Remove B digits from the number A so that the new number is the smallest possible.

Return the resulting smallest possible number after removing B digits from A.

Note: If resulted string is 001000 return 1000.



Input Format

The first argument given is the string A.
The second argument given is the integer B.

Output Format

Return the string containing resulting smallest possible number after removing B digits from A.

Constraints

1 <= N <= 100000
'0' <= A[i] <= '9'
0 <= B <= N
The given num A does not contain any leading zero

For Example

Input 1:
    A = "1432219"
    B = 3
Output 1:
    "1219"

Input 2:
    A = "10"
    B = 2
Output 2:
    '0'
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

Discussion


Loading...
Click here to start solving coding interview questions