JavaScript solution 87ms
\nvar removeKdigits = function(num, k) {\n  let stack = [], numDigits = num.length;\n  for (let i = 0; i < numDigits; i++) {\n    while(k > 0 && stack.length &&
```\nvar removeKdigits = function(num, k) {\n  let stack = [], numDigits = num.length;\n  for (let i = 0; i < numDigits; i++) {\n    while(k > 0 && stack.length && stack[stack.length - 1] > num[i]) {\n        stack.pop();\n        k--;\n    }\n    stack.push(num[i]);\n  }\n  stack = k > 0 ? stack.slice(0, -k) : stack;\n  return stack.join('').replace(/^0+/, '') || '0';\n};\n```
[]