0ms && 100% Faster || Simple || C++ Using Stack
\nstring removeKdigits(string num, int k) {\n\t// Maintain the stack in increasing order from bottom to top\n\tstack<char> st;\n\tfor(int i=0; i<num.size(); i++
```\nstring removeKdigits(string num, int k) {\n\t// Maintain the stack in increasing order from bottom to top\n\tstack<char> st;\n\tfor(int i=0; i<num.size(); i++){\n\t\t// Popping elements if greater than current digit and when k>0\n\t\twhile(!st.empty() && st.top() > num[i] && k>0){\n\t\t\tst.pop();\n\t\t\tk--;\n\t\t}\n\t\tst.push(num[i]);\n\t}\n\n\t// Ex: "12345", k=3\n\t// For the above example, while inserting the elements, no element will be popped\n\t// But we need to remove \'k\' characters \n\t// Hence remove the top k characters\n\twhile(k!=0){\n\t\tst.pop();\n\t\tk--;\n\t}\n\t\n\t// Storing stack elements in ans\n\tstring ans;\n\twhile(!st.empty()){\n\t\tans += st.top();\n\t\tst.pop();\n\t}\n\t\n\t// Removing leading zeroes\n\twhile(ans.back() == \'0\'){\n\t\tans.pop_back();\n\t}\n\t\n\t// Reverse to get the smallest number\n\treverse(ans.begin(), ans.end());\n\n\t// In some cases, ans will be empty such as:\n\t// Ex: num = "9", k=1;  num = "45213" k = 5\n\treturn ans.empty()  ? "0" : ans;\n}\n```\n```\ncout<<"Upvote the solution if you like it!!"<<endl;\n```
['Stack', 'C', 'C++']