C++ solution || Greedy || Stack
\nstring smallestSubsequence(string s) {\n        string ans="";\n       map<char,bool>exists;\n        map<char,int>freq;\n        for(int i=0;i<s.length();i++
```\nstring smallestSubsequence(string s) {\n        string ans="";\n       map<char,bool>exists;\n        map<char,int>freq;\n        for(int i=0;i<s.length();i++){\n            exists[s[i]]=false;\n            freq[s[i]]++;\n        }\n        stack<char>st;\n        st.push(s[0]);\n        exists[s[0]]=true;\n        \n        for(int i=1;i<s.length();i++){\n            if(s[i]<=st.top()){\n                if(exists[s[i]]==false){\n                    while(!st.empty() && s[i]<st.top() && freq[st.top()]>1){\n                        freq[st.top()]--;\n                        exists[st.top()]=false;\n                        st.pop();   \n                    }\n                    st.push(s[i]);\n                    \n                    exists[s[i]]=true;\n                }\n                else{\n                    freq[s[i]]--;\n                    \n                    }\n                }\n            else{\n                if(exists[s[i]]==false){\n                    st.push(s[i]);\n                    exists[s[i]]=true;\n                    \n                }\n            }\n            \n        }\n        while(!st.empty()){\n            ans.push_back(st.top());\n            st.pop();\n        }\n        reverse(ans.begin(),ans.end());\n        return ans;\n    }\n```
['Stack', 'Greedy']