String | C++ | 3ms solution
Remove K Digits\n  Our aim is to remove digit nums[i] starting from left where num[i]>nums[i+1]\n Using stack (here used stack) we compare the top element the p
## Remove K Digits\n*  Our aim is to remove digit nums[i] starting from left where `num[i]>nums[i+1]`\n* Using stack (here used stack) we compare the top element the present element\n* If top element>present element we pop the top element from the stack (or string) and push the present element\n* If more element are still left to be removed i.e k>0 we remove the elements from the end of the string(stack)\n* We check if first element (character) is 0\n\t* if YES then we reverse the string and remove the elements from the end till no zeros are left at the back of the string. Then we reverse the string again.\n\n#### C++\nclass Solution {\npublic:\n    string removeKdigits(string num, int k) {\n        string S="";\n        int n=num.length();\n\t\t\n        S.push_back(num[0]);\n        for(int i=1; i<n; i++)\n        {\n            while(k && S.back()>num[i])\n            {\n                k--;\n                S.pop_back();\n            }\n            S.push_back(num[i]);\n        }\n        while(k && !S.empty())\n        {\n            k--;\n            S.pop_back();\n        }\n        \n        if(S.length()>1 && S[0]==\'0\')\n        {\n            reverse(S.begin(),S.end());\n            while(S.back()==\'0\') S.pop_back();\n            reverse(S.begin(),S.end());\n        }\n        \n       return S==""?"0":S;\n    }\n};\n\nIf it helped, do upvote :)
['String', 'Stack', 'C', 'C++']