Use a stack. For each digit:
While stack top > current digit and k > , pop the stack (remove that digit) and decrement k.
Push current digit. After processing, if k > , remove from the end. Finally, strip leading zeros. Time: . Space: . The stack maintains an increasing sequence of digits from left to right. Each pop removes a 'peak' digit where a smaller digit follows. This ensures leftmost positions contain the smallest possible values. Common bug: forgetting to handle cases where removals finish before scanning all digits.