[Python] Very detail explanation with examples using stack
\nclass Solution:\n    def removeKdigits(self, num: str, k: int) -> str:\n        ## RC ##\n\t\t## APPROACH : STACK ##\n        ## IDEA : 1234, k= 2 => when num
```\nclass Solution:\n    def removeKdigits(self, num: str, k: int) -> str:\n        ## RC ##\n\t\t## APPROACH : STACK ##\n        ## IDEA : 1234, k= 2 => when numbers are in increasing order we need to delete last digits \n        ## 4321 , k = 2 ==> when numbers are in decreasing order, we need to delete first digits\n        ## so, we need to preserve increasing sequence and remove decreasing sequence ##\n\t\t## LOGIC ##\n\t\t#\t1. First think in terms of stack\n\t\t#\t2. push num into stack IF num it is greater than top of stack\n\t\t#\t3. ELSE pop all elements less than num\n\t\t\n        ## TIME COMPLEXICITY : O(N) ##\n\t\t## SPACE COMPLEXICITY : O(N) ##\n\t    \n        stack = []\n        for n in num:\n            while( stack and int(stack[-1]) > int(n) and k):\n                stack.pop()\n                k -= 1\n            stack.append(str(n))\n        \n        # If no elements are removed, pop last elements, (increasing order)\n        while(k):\n            stack.pop()\n            k -= 1\n\n        # removing leading zeros\n        i = 0\n        while( i <len(stack) and stack[i] == "0" ):\n            i += 1\n            \n        return \'\'.join(stack[i:]) if (len(stack[i:]) > 0) else "0"            \n            \n```\nIF YOU LIKE MY SOLUTION, PLEASE UPVOTE.
['Python', 'Python3']