C++ Approach Using Stack , Unorderd_map  and Set
The Below solution uses stack , unordered_map and set into its implementation\n\nstring smallestSubsequence(string s)\n    {\n        stack<char>st;\n        se
The Below solution uses stack , unordered_map and set into its implementation\n```\nstring smallestSubsequence(string s)\n    {\n        stack<char>st;\n        set<char>se;\n        unordered_map<char,int>mp;\n        string res = "";\n        int n = s.length();\n        for(int i=0;i<n;i++)\n        {\n            mp[s[i]] = i;\n        }\n        for(int i=0;i<n;i++)\n        {\n            if(se.find(s[i])!=se.end())\n            {\n                continue;\n            }\n            while(st.empty()!=true && st.top()>=s[i] && mp[st.top()]>i)\n            {\n                int val = st.top();\n                st.pop();\n                se.erase(val);\n            }\n            st.push(s[i]);\n            se.insert(s[i]);\n        }\n        while(st.empty()!=true)\n        {\n            res.push_back(st.top());\n            st.pop();\n        }\n        reverse(res.begin(),res.end());\n        return res;\n    }\n```\n**If you find solution helpful and easy to understand please UPVOTE**\n**Happy Coding**
['Stack', 'Ordered Set', 'C++']