Approach Summary
Monotonic-increasing stack: pop when current digit is smaller than top and k > 0. Strip leading zeros from result.
How to Recognize This Pattern
- "Remove k digits to make smallest number"
- Greedy: always remove the leftmost peak first
Complexity Analysis
Time Complexity
O(n)
Space Complexity
O(n)
Tags
String Stack Greedy Monotonic Stack