Problem Summary
Given string A representative a positive integer which has N digits, remove any k digits of the number, the remaining digits are arranged according to the original order to become a new positive integer.
Find the smallest integer after remove k digits. k ≤ N ≤ 240.
Solution
Removing k digits is actually choosing N-k digits to form a new integer.
Apparently, we should make the top digit minimal.
For any i, 0 ≤ i < N-k, we greedily choose the smallest digit in current range.
Code
|
|