🔥Greedy || ✅Clean Code || 💯Map + Set⚡
\n\n# Complexity\n\n- Time complexity:\nO(n)\n\n- Space complexity:\nO(n)\n\n\n# Code\n## Please Upvote if it helps\uD83E\uDD17\n\nclass Solution {\npublic:\n  
\n\n# Complexity\n```\n- Time complexity:\nO(n)\n\n- Space complexity:\nO(n)\n```\n\n# Code\n## Please Upvote if it helps\uD83E\uDD17\n```\nclass Solution {\npublic:\n    string clearStars(string s) {\n        int n = s.size();\n        map<char, set<int>> mp;\n        unordered_set<int> mark;\n        for(int i = 0 ; i < n ; i++){\n            if(s[i] == \'*\'){\n                char ch = mp.begin() -> first;\n                auto &s = mp.begin() -> second;\n                int val = *s.rbegin();\n                mark.insert(val);\n                s.erase(val);\n                if(!s.size())\n                    mp.erase(ch);\n            }\n            else\n                mp[s[i]].insert(i);\n        }\n        string ans = "";\n        for(int i = 0 ; i < n ; i++){\n            if(s[i] != \'*\' && !mark.contains(i))\n                ans += s[i];\n        }\n        return ans;\n    }\n};\n```
['Ordered Map', 'Ordered Set', 'C++']