Delete Rightmost element
Intuition\n Describe your first thoughts on how to solve this problem. \nMy intuition was we will delete the smallest then it is always good to delete the last 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nMy intuition was we will delete the smallest then it is always good to delete the last index smallest so thats what i did i simply used the set to get the index i should skip.\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)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    string clearStars(string s) {\n        vector<vector<int>>ok(26);\n        set<int>st;\n        for(int i = 0;i<s.size();i++){\n            if(s[i]==\'*\'){\n                for(int j=0;j<26;j++){\n                    if(ok[j].size()>0){\n                        st.insert(ok[j].back());\n                        ok[j].pop_back();\n                        break;\n                    }\n                }\n            }else{\n                ok[s[i]-\'a\'].push_back(i);\n            }\n        }\n        string ans = "";\n        for(int i = 0;i<s.size();i++){\n            if(st.count(i) == false && s[i]!=\'*\'){\n                ans+=s[i];\n            }\n        }\n        return ans;\n    }\n};\n```
['C++']