Easy-Peasy Solution using Set
Intuition\n Describe your first thoughts on how to solve this problem. \njust maintain a sorted set and which is internally sorted based on the index in negativ
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\njust maintain a sorted set and which is internally sorted based on the index in negative order to get the nearest smallest char from left side \n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->o(n)\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->o(n)\n\n# Code\n```\nclass Solution {\npublic:\n    string clearStars(string s) {\n          set<pair<char,int>> st;\n    string res;\n    for(int i=0;i<s.length();i++)\n    {\n        if(s[i]==\'*\')\n        {\n            pair<char,int>p =*st.begin();\n            int del=-(p.second);\n            s[del-1]=\'*\';\n            st.erase(st.begin());\n        }\n        else\n        st.insert({s[i],(i+1)*-1});\n    }\n    cout<<s<<endl;\n    for(auto v:st)\n    cout<<v.first<<" "<<v.second<<endl;\n    for(int i=0;i<s.length();i++)\n    {\n        if(s[i]!=\'*\')res+=s[i];\n    }\n    return res;\n    }\n};\n```
['Ordered Set', 'C++']