C++ | Easy to Understand | using Hashmap🔥✅
\n\n# Complexity\n- Time complexity: O(n)\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\n# Complexity\n- Time complexity: O(n)\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        int n = s.length();\n        vector<char> arr;\n        for (int i = 0;i < n;i++) {\n            arr.push_back(s[i]);\n        }\n        map<char, vector<int>> mp;\n        int i = 0;\n        while (i < n) {\n            if (s[i] != \'*\') {\n                mp[s[i]].push_back(i);\n            }\n            else {\n                arr[mp[mp.begin()->first][mp[mp.begin()->first].size()-1]] = \'/\';\n                mp[mp.begin()->first].pop_back();\n                if (mp[mp.begin()->first].size() == 0) {\n                    mp.erase(mp.begin()->first);\n                }\n            }\n            i++;\n        }\n        string ans = "";\n        for (auto it : arr) {\n            if (int(it) >= 97 and int(it) <= 122) ans += it;\n        }\n        return ans;\n    }\n};\n```
['C++']