[C++] Heap NlogN
\n\n\n\n\nclass Solution {\npublic:\n    struct CompareStruct {\n        bool operator() (pair a, pair b) {\n            if (a.first > b.first) {\n             
\n\n\n\n\nclass Solution {\npublic:\n    struct CompareStruct {\n        bool operator() (pair<int, int> a, pair<int, int> b) {\n            if (a.first > b.first) {\n                return true;\n            } else if (a.first == b.first) {\n                return a.second < b.second;\n            }\n            return false;\n        }\n    };\n    \n    string clearStars(string s) {\n        unordered_set<int> indexesToDelete;\n        priority_queue<pair<int, int>, vector<pair<int, int>>, CompareStruct> heap;\n        \n        \n        for (int i = 0; i < s.size(); i++) {\n            if (s[i] != \'*\') {\n                heap.push({s[i], i});\n            } else {\n                indexesToDelete.insert(heap.top().second);\n                heap.pop();\n            }\n        }\n        \n        string ans = "";\n        for (int i = 0; i < s.size(); i++) {\n            if (indexesToDelete.count(i)) {\n                continue;\n            } else if (s[i] != \'*\') {\n                ans.push_back(s[i]);\n            }\n        }\n        \n        return ans;\n    }\n};\n```
['C++']