JAVA Solution Explained in HINDI
https://youtu.be/iuZWlBBSDBc\n\nFor explanation, please watch the above video and do like, share and subscribe the channel. \u2764\uFE0F Also, please do upvote 
https://youtu.be/iuZWlBBSDBc\n\nFor explanation, please watch the above video and do like, share and subscribe the channel. \u2764\uFE0F Also, please do upvote the solution if you liked it.\n\nSubscribe link:- [ReelCoding](https://www.youtube.com/@reelcoding?sub_confirmation=1)\n\nSubscribe Goal:- 400\nCurrent Subscriber:- 306\n\n# Complexity\n- Time complexity: O(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(n)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    public String removeKdigits(String num, int k) {\n\n        int n = num.length();\n        ArrayDeque<Character> stack = new ArrayDeque<>();\n\n        for (char c : num.toCharArray()) {\n            while (!stack.isEmpty() && stack.peek() > c && k > 0) {\n                stack.pop();\n                k--;\n            }\n            stack.push(c);\n        }\n\n        while (k > 0 && !stack.isEmpty()) {\n            stack.pop();\n            k--;\n        }\n\n        StringBuilder sb = new StringBuilder();\n        while (!stack.isEmpty()) {\n            sb.append(stack.pop());\n        }\n\n        sb.reverse();\n\n        // Remove leading zeros\n        int start = 0;\n        while (start < sb.length() && sb.charAt(start) == \'0\') {\n            start++;\n        }\n\n        sb = sb.delete(0, start);\n\n        // If the string is empty, return "0"\n        if (sb.length() == 0) {\n            return "0";\n        }\n\n        return sb.toString();\n    }\n}\n```
['Java']