JavaScript stack solution
\nvar removeKdigits = function(num, k) {\n    const stack = [];\n    let removed = 0;\n    for(let n of num) {\n        while(stack.length && n < stack[stack.le
```\nvar removeKdigits = function(num, k) {\n    const stack = [];\n    let removed = 0;\n    for(let n of num) {\n        while(stack.length && n < stack[stack.length-1] && removed < k) {\n            stack.pop();\n            removed += 1;\n        }\n        stack.push(n);\n    }\n    \n    // remove all remaining large numbers\n    while(removed < k) {\n        stack.pop();\n        removed += 1;\n    }\n    \n    // remove all beginning zeroes\n    while(stack.length && stack[0] === \'0\') {\n        stack.shift();\n    }\n    \n    return stack.length ? stack.join(\'\') : \'0\';\n};\n```
['Stack', 'JavaScript']