java easy to understand | using stack & stringBuilder
\nclass Solution {\n    public String removeKdigits(String num, int k) {\n        \n        Stack<Character> st = new Stack<>();\n        \n        for(int i=0;
```\nclass Solution {\n    public String removeKdigits(String num, int k) {\n        \n        Stack<Character> st = new Stack<>();\n        \n        for(int i=0;i<num.length();i++)\n        {\n            char ch = num.charAt(i);\n            while(st.size() >0 && k >0 && st.peek() > ch)\n            {\n                st.pop();\n                k--;\n            }\n            st.push(ch);\n        }\n        \n        while(k>0)\n        {\n            st.pop();\n            k--;\n        }\n        StringBuilder ans = new StringBuilder();\n        \n        while(st.size()>0)\n            ans.insert(0,st.pop());\n        \n        while(ans.length()>0 && ans.charAt(0) == \'0\')\n            ans.delete(0,1);\n        if(ans.length() == 0)\n            return "0";\n        return ans.toString();\n    }\n}\n```\nPlease upvote if u find my code easy to understand
['Stack', 'Java']