Loading...
Loading...
Loading...
A number is given as digits. Remove exactly k digits so that the remaining number is as small as possible. The digits keep their order. Print the result without leading zeros. If nothing is left, print 0.
Example 1
Input
1432219 3
Output
1219
Remove 4, 3 and 2 to get 1219.
Example 2
Input
10200 1
Output
200
Try the problem first. Open one hint at a time.
Go left to right. If the last kept digit is bigger than the new digit, removing it makes the number smaller.
If removals are left at the end, drop digits from the right.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor