C++ 100% time and space solution
\tclass Solution {\n\tpublic:\n\t\tstring smallestSubsequence(string text) {\n\t\t\tunordered_map m;\n\t\t\tfor(int i=0;i<text.size();i++){\n\t\t\t\tm[text[i]]=
\tclass Solution {\n\tpublic:\n\t\tstring smallestSubsequence(string text) {\n\t\t\tunordered_map<char,int> m;\n\t\t\tfor(int i=0;i<text.size();i++){\n\t\t\t\tm[text[i]]=i;\n\t\t\t}\n\t\t\tstring ans;\n\t\t\tunordered_set<char> visited;\n\t\t\tfor(int i=0;i<text.size();i++){\n\t\t\t\twhile(!visited.count(text[i]) && !ans.empty() && text[i]<ans.back() && m[ans.back()]>i){\n\t\t\t\t\tvisited.erase(ans.back());\n\t\t\t\t\tans.pop_back();\n\t\t\t\t}\n\t\t\t\tif(!visited.count(text[i])){\n\t\t\t\t\tans+=text[i];\n\t\t\t\t\tvisited.insert(text[i]);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn ans;     \n\t\t}\n\t};
['C', 'C++']