String by Deletions
You are given a decimal string s and an integer k.
Delete exactly k digits from s so that the remaining digits, in their original order, form the smallest possible number.
If the resulting number has leading zeroes, do not print them. If every digit is deleted, or the
result is all zeroes, print 0.
Input
The first line contains the string s.
The second line contains the integer k.
Output
Print the smallest possible number after deleting exactly k digits.
Constraints
- 1≤∣s∣≤2⋅105
- 0≤k≤∣s∣
- s consists only of digits
0through9
Example 1
1432219
3
1219
Explanation
Deleting the digits 4, 3, and 2 gives the smallest possible result.
Example 2
10200
1
200
Explanation
Deleting the leading 1 gives 0200, which is printed as 200.
Example 3
10
2
0
Comments0
No comments yet
Be the first to comment.
New comment
Log in to join the discussion.