[C++] || MonoStack
\nclass Solution {\npublic:\n    string smallestSubsequence(string s) {\n        string ans = "" ;\n        int f[26] = {} , taken[26] = {} ;\n        for(auto 
```\nclass Solution {\npublic:\n    string smallestSubsequence(string s) {\n        string ans = "" ;\n        int f[26] = {} , taken[26] = {} ;\n        for(auto &x : s) ++f[x-\'a\'] ;\n        \n        for(auto &x : s){\n            --f[x-\'a\'] ;\n            while(ans.size() and x < ans.back() and f[ans.back() - \'a\'] and !taken[x-\'a\']) taken[ans.back()-\'a\'] = 0 , ans.pop_back() ;\n            if(!taken[x-\'a\']) ans.push_back(x) , taken[x-\'a\'] = 1 ; \n        }\n        \n        return ans ;\n    }\n};\n```
['C']