Easiest C++ Solution
\n\n# Approach\n Describe your approach to solving the problem. \n- The approach used here is to simulate the process of building the final number string while 
\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n- The approach used here is to simulate the process of building the final number string while removing k digits.\n- We use a vector (stk) to simulate a stack, where we keep pushing elements as long as they are non-increasing. Whenever we encounter a smaller element, we pop elements from the stack until the condition is satisfied or until we exhaust the k removals.\n- After processing all elements, if k is still greater than zero, we pop elements from the stack to fulfill the remaining removals.\n- Finally, we construct the output string from the remaining elements in the stack.\n- This approach ensures that the output string contains the smallest possible number after removing k digits.\n- The intuition behind this approach is to keep track of the digits in a way that we can easily make decisions about which digits to remove while constructing the smallest number. By simulating the process of building the number and removing digits as needed, we arrive at the desired result efficiently.\n\n# Complexity\n- Time complexity:O(N)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:O(N-K) ~ O(N)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n    N- Length of the string\n# Code\n```\nclass Solution {\npublic:\n    string removeKdigits(string num, int k) {\n        vector<char>stk;\n        string ans;\n        for(char c :num){\n            while(k>0 && !stk.empty() && stk.back()>c){\n                stk.pop_back();\n                k--;\n            }\n            stk.push_back(c);\n        }\n        while(k>0){\n            stk.pop_back();\n            k--;\n        }\n        for(char c : stk){\n            if(ans.empty() && c==\'0\') continue;\n            ans.push_back(c);\n\n        }\n        return ans.empty()?"0":ans;\n    }\n};\n```
['C++']