Short & Simple Code | Only using Priority queue🔥✅ | No Custom Comparator
Approach\n Describe your approach to solving the problem. \n1. Initialization:\n   - The priority queue pq is defined to store pairs of characters and their ind
# Approach\n<!-- Describe your approach to solving the problem. -->\n1. **Initialization**:\n   - The priority queue `pq` is defined to store pairs of characters and their indices, ordered by the character in ascending order.\n\n2. **Processing the String**:\n   - Iterate over the string `s`.\n   - If the character is not `*`, push it along with its negative index into the priority queue.\n   - If the character is `*`, pop the top element from the priority queue (i.e., the smallest character) and mark its position in `s` with `#`.\n\n3. **Building the Result**:\n   - Traverse the modified string `s`, and construct a new string `ans` excluding all `#` and `*` characters.\n\nThis approach retains the same functionality but is more concise and clear, making it easier to understand.\n# Complexity\n- Time complexity: O(nlogn)\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 {\npublic:\n    string clearStars(string s) {\n        priority_queue<pair<char,int>,vector<pair<char,int>>,greater<pair<char,int>>>pq;\n        for(int i=0;i<s.length();i++){\n            if(s[i]!=\'*\') pq.push({s[i],-i});\n            else{\n                char ch=pq.top().first;\n                int idx=abs(pq.top().second);\n                pq.pop();\n                s[idx]=\'#\';\n            }\n        }\n        string ans="";\n        for(int i=0;i<s.length();i++){\n            if(s[i]!=\'#\' && s[i]!=\'*\') ans.push_back(s[i]);\n        }\n        return ans;\n    }\n};\n```
['C++']