For example consider N = 234987, K = 2, we can remove 9,8 and the resulting number is 2347.
The solution is based on the following observation, consider the above case.
What if all the digits are in ascending order?
Let us walk through an example.
N = 12345, K = 3. If we remove 4,5 we will get the minimum number. The observation is that we need to keep on removing right-most digits in this case.
[This is a re-post after correcting my incorrect approach. Thanks to Jeff Senecal for pointing out the mistake.]
Here is the C++ implementation of the above approach.