Meme se Samajhna hai aajao Smjha dunga 😂 (iykyk-kuchch yaad aaya) || Hindi Explanation 🤷‍♂️ || C++
Intuition\n Describe your first thoughts on how to solve this problem. \n chinta mat kro stack aur bina stack dono ko code bhi dunga and explain bhi kar dunga\n
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n* chinta mat kro stack aur bina stack dono ko code bhi dunga and explain bhi kar dunga\n* aakhir stack wala kaise aaya dimak me\n* dekho n jab bhi mujhe aisa feel hota hai ki mai ith ind pe hu\n* aur us ith ind se mujhe pichche jake kuchch karna jo just uske baad\nwale ho, to phir mai stack se hi sochta hu.\n* intution to pta chal hi gya hoga\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n* 2 tarike hai stack se aur simaple wala dono dekhte hai\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\n// stack wala\nclass Solution {\npublic:\n    string removeKdigits(string num, int k) {\n        stack<char> st; \n        int n=num.size();\n\n\n        // dekho socho agr string ki lenth 1 hai \n        // and  k>=1 to sare elements nikal jayenge to \n        // minimum num kya bna zero bhai, string nhi num puchcha hai\n        // thik.\n        if(num.size()==1 && k>=1) return "0";\n\n        // agr jayda elments htana hai jitna tumhare pass hai\n        // to baat hi khatam n, sab hat jayenge\n        if(num.size()<=k) return "0";\n\n        for(int i=0;i<n;i++){\n\n            // stack hai bnharo bhai pehle\n            // khali jeb kya hi kar payenge\n            if(st.size()==0){\n                st.push(num[i]);\n            }else{\n\n                // agr opr kar skta hu htane tabhi karunga n\n                // shakti hai hmare pass abhi\n                if(k){\n                    // ye dobara k kyu maine likha (while me )\n                    // sayad nashe me rha hounga koi na \n                    // hota hai sad life\n                    // aisa kuchch nhi hai ki nashe me hu\n                    // k ghta rhe hai har iteration me\n                    // esiliye check kar rha hu ki\n                    // abhi number htane ki shakti hai na nhi \uD83D\uDE00\uD83D\uDE00\n\n                    // lekin ek min, ye if ki to need hi nhi hai\n                    // paisa barbad ....(carry minati- IYKYK \uD83D\uDE02)\n                    while(k!=0 && !st.empty() && st.top() > num[i]){\n                        st.pop();k--;\n                    }\n                }\n                // push kar de bhai jo bhi number hai\n                // pta nhi ye kitne ko htaya hoga \n                // same string character removes the another \n                // character and shows supermacy\n                // condition ke according\n\n                // then dusara character be like\n                // Gaddari karbe..\uD83D\uDE02\n                st.push(num[i]);\n            }\n        }\n\n        // bhai abhi bhi k hai yani shakti hai\n        // elements htao phir baat hi khatam\n        // ye nhi increasing order ke liye hai\n        // "1234" k>=1\n        // tab n uper wale loop me kuchch erase nhi higa esiloiye\n        // eski need padi\n        // kyuki uski condition dekho samjh jaoge\n\n        // dhyan knha hai tumhara kya keh rhe \n        // kisi khash pe \uD83D\uDE02\n        while(k--) st.pop();\n\n        // ans bna rhe\n        string ans="";\n        while(!st.empty()) {\n            ans.push_back(st.top());st.pop();\n        }\n\n\n        // ye n start ke zero htane ke liye use akr rha\n        // arey bhai ki number "0023" to nhi n hai\n        // hai to "23" kar do bas simple\n        char c=ans.back();\n        while(ans.size()>0 && c==\'0\' && ans.back()==c) ans.pop_back();\n        \n        // ye to stack ke que ki parampara hai\n        // ye to karna hi hota hai \uD83D\uDE02\uD83D\uDE02\uD83D\uDE02\n        reverse(ans.begin(),ans.end()); \n\n        // agr zero htane ke baad khali ho gya to zero bhej do \n        if(ans.size()==0) ans.push_back(\'0\');\n\n        // ans return kro streak bnao\n\n        // arey ruk jao bhai dusra approach dekhate hai\n        return ans;\n    }\n};\n\n// end huaa ymhi\n\n\n\n\n\n\n\n\n// without stack wala\nclass Solution {\npublic:\n    string removeKdigits(string num, int k) {\n\n        // dekho stack yani simple array jo array ke last me \n        // vo stack ke top me \n\n        // tu smjha..nhi samjha (image meme) \uD83D\uDE02\n\n        string ans=""; \n\n        int n=num.size();\n\n        // uper explain kiya tha\n        // lekin us time nashe me tha n\n        // to do baar likha tha\n        // constraint me k ki minimum value 1 hogi hi\n        if(n==1 || n<=k) return "0";\n\n        for(auto it:num){\n            // simple vhi condition\n            while(ans.size()>0 && ans.back() > it && k){\n                ans.pop_back();\n                k--;\n            }\n\n            // dekho agr ans khali hai to aagr char\n            // zero hao to push nhi karenge\n            // kyu 0 se start hoga\n            // to koi sense to bnta hi nhi hai\n            // "023" kya matlab ? "23" good\n            if(ans.size()!=0 || it!=\'0\') ans.push_back(it);\n        }\n\n\n        // bcha hai pop kar do bhai \n        // increasing order mke honge\n        while(ans.size()>0 && k--) ans.pop_back();\n\n        // khali hai zero bhej do nhi to ans\n\n        // khalipan khalipan jindagi me khali pan\n\n        // milta hu next solution ke meme me tab tak ke liye\n        // machate rho, DSA ke pyaar me dubate rho\n        // kya keh rhe abhi bhai, duba to kisi\n        // aur ke pyaar me ho \u2764\uFE0F\n        return ans.size()==0 ? "0": ans;\n    }\n};\n```
['C++']