C++ || Priority-queue || EASY-PEASY
\n\n# Code\n\nclass compare {\npublic:\n    bool operator()(pair<char, int> a, pair<char, int> b) {\n        if(a.first == b.first)\n            return a.second
\n\n# Code\n```\nclass compare {\npublic:\n    bool operator()(pair<char, int> a, pair<char, int> b) {\n        if(a.first == b.first)\n            return a.second < b.second;\n        else \n            return a.first > b.first;\n    }\n};\n\nclass Solution {    \npublic:\n    string clearStars(string s) {\n        int len = s.length();\n        priority_queue<pair<char, int>, vector<pair<char, int>>, compare> pq;\n        string ans;\n        \n        for(int i = 0; i < len; i++) {\n            if(s[i] != \'*\')\n                pq.push({s[i], i});\n            else {\n                char smallCh = pq.top().first;\n                int smallIdx = pq.top().second;\n                pq.pop();\n                s[smallIdx] = s[i] = \'#\';\n            }\n            \n        }\n        \n        for(auto ch : s) {\n            if(ch != \'#\')\n                ans.push_back(ch);\n        }\n        \n        return ans;\n    }\n};\n```
['Heap (Priority Queue)', 'C++']