EASY C++ SOLUTION USING MIN HEAP
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```cpp []
class Solution {
    struct mycomp{
        bool operator()(pair<char, int>&a, pair<char, int>&b)
        {
            if(a.first == b.first)
            return a.second < b.second;

            return a.first > b.first;
        }
    };
   
public:
    string clearStars(string s) {
        priority_queue<pair<char, int>, vector<pair<char, int>>, mycomp>pq;
        int n = s.length();

        for(int i=0; i<n; i++)
        {
            if(s[i] == '*')
            {
                if(pq.size() == 0)
                continue;
                else
                {
                    pair<char, int>curr = pq.top();
                    pq.pop();
                    s[curr.second] ='#';
                }
            }
            else
            {
                pq.push({s[i], i});
            }
        }

        string answer = "";

        for(auto x: s)
        {
            if(x == '#' || x == '*')
            continue;

            answer += x;
        }

        return answer;
        
    }
};
```
['Heap (Priority Queue)', 'C++']