Dekh 👁️ rha hai Vinod 🤦‍♂️ Solve kr liya 😂 || Hindi 🔥 Explanation || C++ Solution
Intuition\n Describe your first thoughts on how to solve this problem. \n sab milega code me milega\n# Approach\n Describe your approach to solving the problem.
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n* sab milega code me milega\n# Approach\n<!-- Describe your approach to solving the problem. -->\n* code me approach lelo, approach lelo\n\n# Complexity\n* Time Complexity:- O(n log n)\n* Space Complexity:- O(n)\n# Code\n```\n\nclass Solution {\npublic:\n    \n   \n/*\nAakhir es que me jo bola hai, uska matlab huaa, * ke nearest ka minimum element jo bhi ho use delete kr do\n\nClear statement nhi lga(aao samjhata hu)\n\n(......................)*\nye dot * ke aane ke pehle ka subarray hai thik,\nto hme sabse minimum choose krna hai, character ko.\n\nto tum bologe Abhishek bhai, to phir sidhe bolane ka n, ye complex karke kyu bola tumne\n* ke nearest ka minimum element jo bhi ho\n\nGajab ho tum Abhishek bhai, aasan rakhne ka, complex kar rhe faltu ka\n\nArey bhai thamba thamba, dekho dekho aise bolna jaruri hai kyuki\n\naao dikhata hu\n\n(aaba)*\nto kaun sa a htavoge, es range me to minimum a hai, bolo bolo\narey bolte kyu nhi..\n\nSamjhe to jo minimum elements hai, usme jo sabse pass hai * ke usko htana hai\n\nto tum keh rhe abhishek bhai ye to complex lag rha,\narey tumhara bhai, rumhare sath hai chinta nhi karne ka, aasan karna mera kaam\n\n(.....................) *\n\nachcha to hme koi aisa jadu karna hai, jisse ki hme use dot dot ka minimum element mil jaye\n\nAudience be like :- mai samjh gya, mai samjh gya \nmai ya to (minPQ, multiset) use kr lunga\n\nthik thik hai, ruk jao itna khush mat hovo\n\nminPQ me vo element top me hoga jiski value minimum hogi.\nAudience:- ekdam thik bola tumne\nAbhishek:- achcha ek baat btavo minPQ kya karta hai jab same element hota hai.\n\nAudience:- Aaye...e ka bol diye, dekh rha hai binod, tej ban rha hai\n\nAbhishek:- guss na hoiye malik, achcha ek baat hai mai PQ me index ke sath elment ko rakhuga\nAudience:- kyu, terese aasani se kaam nhi hota kaa..\nAbhishek:- arey pop karte time kaise pta chalega ki kaun sa element huaa hai\n\nAudience:- thik hai thik hai, ham samjh gye the, tumhara knowledge check kr rhe the, aati hi hai ya bas bolte ho\n\nAbhishek:- thik to agree karte ho index ko sath rakhna hai character ke, thik. achcha ek baat btavo agar mai ind bhi rakha hai aur\n            do character hai same hai to top pe kaun hoga \n            string => caa*\n            Que time :- {a,1},{a,2};\n            to top pe kaun hoga ? {a,1} ya {a,2}=> {a,1} n ye to fash gye\n    \n    Audience dar gyi Audience dar gyi \n    \nab bolo binod.\n\nAudience:- be like, ka bawasir que hai, ek chij socho ek chij pe fash jaoo\n\nAbhishek:- dekho agr kaisa ho ki first value min ho and second value maximum agr vo top pe aa jaye to mza hi aa jaye\n\nAudience:- e kaise hoga\n\nAbhishek:- bole to comperator se bhaiya\n\n        mazak se hat ke, agr comperator se familiar nhi ho to YT pe video dekh lena(comperator ki, kisi aur ki mat dekhna)\n        \n        \nbas que khatam, * aaye PQ ke top ko pop karo and kaam khatam.\nLekin ek minute aakhir tum answer wala string kab banaoge\n\ndekho jab jab jo pop hoga, uski index mark kar dunga, phir pura traverse krke, unmark ind ko add kr dunga simple hai simple hai\n\nAudience:- Samjh aa gya, tere explanation me daam nhi th, hmare dimak me daam hai \n\n\nAgr doubt hai to feel free to ask in comment section, baaki milte hai kabhi...dusari post me \n*/\n     \n    \n    struct Compare {\n        bool operator()(const pair<int, int>& a, const pair<int, int>& b) {\n            if (a.first == b.first)\n                return a.second < b.second;  \n            return a.first > b.first; \n        }\n    };\n    \n    string clearStars(string s) {\n        int n=s.size();\n        string ans="";\n\n        // ascii code to suna hi hoga tumne\n       priority_queue<pair<int, int>, vector<pair<int, int>>, Compare> pq;\n\n        // hint bina comperator ke possible hai, if tum index ko\n        // -1 se multiply krke push kro, minPQ me to\n        // vis[ind] krte time, abs le lena bas(try krke dekh lo)\n        \n        vector<int> vis(n,0);\n        \n        for(int i=0;i<n;i++){\n            if(s[i]==\'*\'){\n                // jo pop visit kar diya\n                vis[pq.top().second]=1;\n                pq.pop();\n                \n                // ye star ko visit kar rha, vo to answer ka hissa hoga hi nhi\n                vis[i]=1;\n            }else{\n                // ascii ka kamal\n                pq.push({s[i],i});\n            }\n        }\n        \n        for(int i=0;i<n;i++){\n            // jo visit nhi vo answer me jayega\n            if(vis[i]==0){\n                ans.push_back(s[i]);\n            }\n        }\n        \n        return ans;\n    }\n};\n```
['Heap (Priority Queue)', 'C++']