Faster than 98% and less space than 100 % with just a little change
\nclass Solution:\n    def removeKdigits(self, num: str, k: int) -> str:\n        \n        res = []\n        counter = 0\n        n = len(num)\n        \n     
\nclass Solution:\n    def removeKdigits(self, num: str, k: int) -> str:\n        \n        res = []\n        counter = 0\n        n = len(num)\n        \n        if n == k: return "0"\n        \n        for i in range(n):\n            while k and res and res[-1] > num[i]:\n                res.pop()\n                k -= 1\n            res.append(num[i])\n\n        \n        while k:\n            res.pop()\n            k -= 1\n            \n        return "".join(res).lstrip(\'0\') or "0"\n                \n
['Python', 'Python3']