🔥Very Easy to understand and intuitive 🔥approach.Beginner friendly
\n\n# Complexity\n- Time complexity:\n O(nlogn) \n\n- Space complexity:\n O(n) \n\n# Code\n\nclass Solution {\npublic:\n    string clearStars(string s) {\n     
\n\n# Complexity\n- Time complexity:\n $$O(nlogn)$$ \n\n- Space complexity:\n $$O(n)$$ \n\n# Code\n```\nclass Solution {\npublic:\n    string clearStars(string s) {\n        set<pair<char,int>>st;\n        int c=0;\n        for(auto i:s)\n        {\n            if(i==\'*\')\n            {\n                if(st.size())\n                {\n                    st.erase(st.begin());\n                }\n            }\n            else\n            {\n                st.insert({i,-c});\n            }\n            c++;\n        }\n        vector<pair<int,char>>v;\n        for(auto i:st)\n        {\n            v.push_back({-i.second,i.first});\n        }\n        sort(v.begin(),v.end());\n        string ans;\n        for(auto i:v)ans.push_back(i.second);\n        return ans;\n            \n    }\n};\n```
['Ordered Set', 'C++']